diff --git a/source/streamio/classes/form/edit_resource.php b/source/streamio/classes/form/edit_resource.php index 23dc230..2cb46d9 100644 --- a/source/streamio/classes/form/edit_resource.php +++ b/source/streamio/classes/form/edit_resource.php @@ -96,6 +96,11 @@ public function definition_after_data() { $resource = new media_resource($record); $videourl = $resource->video_url($OUTPUT); + if (substr($videourl, -5) == '.m3u8') { + $type = 'video/x-mpegURL'; + } else { + $type = resourcelib_guess_url_mimetype($videourl); + } $content = [ 'poster' => $resource->image_url($OUTPUT), 'elementid' => 'video-' . uniqid(), @@ -107,7 +112,7 @@ public function definition_after_data() { 'autoplay' => false, 'option_loop' => false, 'muted' => true, - 'type' => resourcelib_guess_url_mimetype($videourl), + 'type' => $type, ]), ]; $mform->insertElementBefore( diff --git a/source/streamio/classes/output/media_resource.php b/source/streamio/classes/output/media_resource.php index 90c8f56..df80a55 100644 --- a/source/streamio/classes/output/media_resource.php +++ b/source/streamio/classes/output/media_resource.php @@ -63,6 +63,11 @@ public function export_for_template(renderer_base $output) { global $DB, $USER; $context = \context_system::instance(); $videourl = $this->video_url($output); + if (substr($videourl, -5) == '.m3u8') { + $type = 'video/x-mpegURL'; + } else { + $type = resourcelib_guess_url_mimetype($videourl); + } $content = [ 'elementid' => 'video-' . uniqid(), @@ -74,7 +79,7 @@ public function export_for_template(renderer_base $output) { 'autoplay' => false, 'option_loop' => false, 'muted' => true, - 'type' => resourcelib_guess_url_mimetype($videourl), + 'type' => $type, ]), 'poster' => $this->image_url($output), ]; diff --git a/source/streamio/templates/video.mustache b/source/streamio/templates/video.mustache index dc2d297..58cc435 100644 --- a/source/streamio/templates/video.mustache +++ b/source/streamio/templates/video.mustache @@ -38,7 +38,7 @@ id="{{ elementid }}" controls class="video-js" - poster="https://{{ screenshot.normal }}" + poster="{{ poster }}" >

@@ -48,6 +48,7 @@ return true; }; var v = new VideoTime('{{ elementid }}', 0, 0, 0, {{{instance}}}); + console.log(['{{ elementid }}', 0, 0, 0, {{{instance}}}]); v.initialize(); }); {{/js}} diff --git a/source/videotime/classes/form/edit_resource.php b/source/videotime/classes/form/edit_resource.php index be83e6a..6257895 100644 --- a/source/videotime/classes/form/edit_resource.php +++ b/source/videotime/classes/form/edit_resource.php @@ -138,6 +138,11 @@ public function definition_after_data() { $resource = new media_resource($record); $videourl = $resource->video_url($OUTPUT); + if (substr($videourl, -5) == '.m3u8') { + $type = 'video/x-mpegURL'; + } else { + $type = resourcelib_guess_url_mimetype($videourl); + } $content = [ 'poster' => $resource->image_url($OUTPUT), @@ -150,7 +155,7 @@ public function definition_after_data() { 'autoplay' => false, 'option_loop' => false, 'muted' => true, - 'type' => resourcelib_guess_url_mimetype($videourl), + 'type' => $type, ]), ]; $mform->insertElementBefore( diff --git a/source/videotime/classes/output/media_resource.php b/source/videotime/classes/output/media_resource.php index 5da70de..1f34333 100644 --- a/source/videotime/classes/output/media_resource.php +++ b/source/videotime/classes/output/media_resource.php @@ -72,6 +72,11 @@ public function __construct(stdClass $record) { public function export_for_template(renderer_base $output) { global $DB, $USER; $videourl = $this->video_url($output); + if (substr($videourl, -5) == '.m3u8') { + $type = 'video/x-mpegURL'; + } else { + $type = resourcelib_guess_url_mimetype($videourl); + } $content = [ 'elementid' => 'video-' . uniqid(), @@ -82,7 +87,7 @@ public function export_for_template(renderer_base $output) { 'muted' => true, 'option_loop' => false, 'responsive' => true, - 'type' => resourcelib_guess_url_mimetype($videourl), + 'type' => $type, 'vimeo_url' => $videourl, ]), 'poster' => $this->image_url($output),