Skip to content
Permalink
Browse files

MDL-58472 videojs: Force manual initialise

If we let videojs auto-init the video/audio tags present in the page - we cannot guarantee that the
youtube library will be loaded by the time video.js is processing the tag.

Video.js uses the presence of a data-setup attibute to signal that it should auto-init this tag, so
we have to rename our config attribute to something else.
  • Loading branch information...
damyon committed Jun 9, 2017
1 parent 7624f86 commit 812255766185f2fd37b325b6d316496daf52299a

Some generated files are not rendered by default. Learn more.

@@ -62,7 +62,7 @@ define(['jquery', 'core/event'], function($, Event) {
.addBack(selector)
.find('audio, video').each(function() {
var id = $(this).attr('id'),
config = $(this).data('setup'),
config = $(this).data('setup-lazy'),
modules = ['media_videojs/video-lazy'];

if (config.techOrder && config.techOrder.indexOf('youtube') !== -1) {
@@ -129,8 +129,13 @@ public function embed($urls, $name, $width, $height, $options) {
}
// Attributes for the video/audio tag.
// We use data-setup-lazy as the attribute name for the config instead of
// data-setup because data-setup will cause video.js to load the player as soon as the library is loaded,
// which is BEFORE we have a chance to load any additional libraries (youtube).
// The data-setup-lazy is just a tag name that video.js does not recognise so we can manually initialise
// it when we are sure the dependencies are loaded.
$attributes = [
'data-setup' => '{' . join(', ', $datasetup) . '}',
'data-setup-lazy' => '{' . join(', ', $datasetup) . '}',
'id' => 'id_videojs_' . uniqid(),
'class' => get_config('media_videojs', $isaudio ? 'audiocssclass' : 'videocssclass')
];
@@ -230,7 +230,7 @@ public function test_embed_media() {
protected function youtube_plugin_engaged($t) {
$this->assertContains('mediaplugin_videojs', $t);
$this->assertContains('data-setup="{"techOrder": ["youtube"]', $t);
$this->assertContains('data-setup-lazy="{"techOrder": ["youtube"]', $t);
}
/**

0 comments on commit 8122557

Please sign in to comment.
You can’t perform that action at this time.