YouTube links werkend
This commit is contained in:
@@ -62,9 +62,7 @@
|
|||||||
|
|
||||||
@if($item->video)
|
@if($item->video)
|
||||||
@include('widgets/mediaplayer')
|
@include('widgets/mediaplayer')
|
||||||
<video controls>
|
@php(createVideoElement($item->video))
|
||||||
<source src="{!!$item->video!!}" type="application/x-mpegurl" />
|
|
||||||
</video>
|
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@if($item->source && $item->source->show)
|
@if($item->source && $item->source->show)
|
||||||
|
|||||||
@@ -2,6 +2,17 @@
|
|||||||
if(!isset($MEDIAPLAYER_INCLUDED)):
|
if(!isset($MEDIAPLAYER_INCLUDED)):
|
||||||
// Make sure mediaplayer JS is not applied more than once on a page.
|
// Make sure mediaplayer JS is not applied more than once on a page.
|
||||||
View::share('MEDIAPLAYER_INCLUDED', true);
|
View::share('MEDIAPLAYER_INCLUDED', true);
|
||||||
|
|
||||||
|
function createVideoElement($url) {
|
||||||
|
$type = "application/x-mpegurl";
|
||||||
|
if(strpos($url, "youtube.com") !== false) { $type = "video/youtube"; }
|
||||||
|
if(strpos($url, "youtu.be") !== false) { $type = "video/youtube"; }
|
||||||
|
?>
|
||||||
|
<video controls>
|
||||||
|
<source src="{!!$url!!}" type="{!!$type!!}" />
|
||||||
|
</video>
|
||||||
|
<?php
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
@push('scripts')
|
@push('scripts')
|
||||||
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/mediaelement/4.2.16/mediaelement-and-player.min.js"></script>
|
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/mediaelement/4.2.16/mediaelement-and-player.min.js"></script>
|
||||||
|
|||||||
Reference in New Issue
Block a user