YouTube links werkend
This commit is contained in:
@@ -62,9 +62,7 @@
|
||||
|
||||
@if($item->video)
|
||||
@include('widgets/mediaplayer')
|
||||
<video controls>
|
||||
<source src="{!!$item->video!!}" type="application/x-mpegurl" />
|
||||
</video>
|
||||
@php(createVideoElement($item->video))
|
||||
@endif
|
||||
|
||||
@if($item->source && $item->source->show)
|
||||
|
||||
@@ -2,6 +2,17 @@
|
||||
if(!isset($MEDIAPLAYER_INCLUDED)):
|
||||
// Make sure mediaplayer JS is not applied more than once on a page.
|
||||
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')
|
||||
<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