Commit 4a237e93 authored by Eloy Lafuente's avatar Eloy Lafuente
Browse files

Merge branch 'wip-MDL-57608-master-3' of git://github.com/marinaglancy/moodle

parents 419b2f17 da06c819
...@@ -56,7 +56,8 @@ lib/amd/src/chartjs-lazy.js ...@@ -56,7 +56,8 @@ lib/amd/src/chartjs-lazy.js
lib/maxmind/GeoIp2/ lib/maxmind/GeoIp2/
lib/maxmind/MaxMind/ lib/maxmind/MaxMind/
lib/ltiprovider/ lib/ltiprovider/
media/player/videojs/amd/src/ media/player/videojs/amd/src/video-lazy.js
media/player/videojs/amd/src/Youtube-lazy.js
media/player/videojs/videojs/ media/player/videojs/videojs/
mod/assign/feedback/editpdf/fpdi/ mod/assign/feedback/editpdf/fpdi/
repository/s3/S3.php repository/s3/S3.php
......
...@@ -57,7 +57,8 @@ lib/amd/src/chartjs-lazy.js ...@@ -57,7 +57,8 @@ lib/amd/src/chartjs-lazy.js
lib/maxmind/GeoIp2/ lib/maxmind/GeoIp2/
lib/maxmind/MaxMind/ lib/maxmind/MaxMind/
lib/ltiprovider/ lib/ltiprovider/
media/player/videojs/amd/src/ media/player/videojs/amd/src/video-lazy.js
media/player/videojs/amd/src/Youtube-lazy.js
media/player/videojs/videojs/ media/player/videojs/videojs/
mod/assign/feedback/editpdf/fpdi/ mod/assign/feedback/editpdf/fpdi/
repository/s3/S3.php repository/s3/S3.php
......
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
...@@ -24,7 +24,7 @@ THE SOFTWARE. */ ...@@ -24,7 +24,7 @@ THE SOFTWARE. */
if(typeof exports==='object' && typeof module!=='undefined') { if(typeof exports==='object' && typeof module!=='undefined') {
module.exports = factory(require('video.js')); module.exports = factory(require('video.js'));
} else if(typeof define === 'function' && define.amd) { } else if(typeof define === 'function' && define.amd) {
define(['media_videojs/video'], function(videojs){ define(['media_videojs/video-lazy'], function(videojs){
return (root.Youtube = factory(videojs)); return (root.Youtube = factory(videojs));
}); });
} else { } else {
......
...@@ -22,14 +22,23 @@ ...@@ -22,14 +22,23 @@
* @copyright 2016 Frédéric Massart - FMCorz.net * @copyright 2016 Frédéric Massart - FMCorz.net
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/ */
define(['jquery', 'media_videojs/video', 'core/event'], function($, videojs, Event) { define(['jquery', 'core/event'], function($, Event) {
/**
* Stores the method we need to execute on the first load of videojs module.
*/
var onload;
/** /**
* Set-up. * Set-up.
* *
* Adds the listener for the event to then notify video.js. * Adds the listener for the event to then notify video.js.
* @param {Function} executeonload function to execute when media_videojs/video is loaded
*/ */
var setUp = function() { var setUp = function(executeonload) {
onload = executeonload;
// Notify Video.js about the nodes already present on the page.
notifyVideoJS(null, $('body'));
// We need to call popover automatically if nodes are added to the page later. // We need to call popover automatically if nodes are added to the page later.
Event.getLegacyEvents().done(function(events) { Event.getLegacyEvents().done(function(events) {
$(document).on(events.FILTER_CONTENT_UPDATED, notifyVideoJS); $(document).on(events.FILTER_CONTENT_UPDATED, notifyVideoJS);
...@@ -53,9 +62,20 @@ define(['jquery', 'media_videojs/video', 'core/event'], function($, videojs, Eve ...@@ -53,9 +62,20 @@ define(['jquery', 'media_videojs/video', 'core/event'], function($, videojs, Eve
.addBack(selector) .addBack(selector)
.find('audio, video').each(function() { .find('audio, video').each(function() {
var id = $(this).attr('id'), var id = $(this).attr('id'),
config = $(this).data('setup'); config = $(this).data('setup'),
modules = ['media_videojs/video-lazy'];
videojs(id, config); if (config.techOrder && config.techOrder.indexOf('youtube') !== -1) {
// Add YouTube to the list of modules we require.
modules.push('media_videojs/Youtube-lazy');
}
require(modules, function(videojs) {
if (onload) {
onload(videojs);
onload = null;
}
videojs(id, config);
});
}); });
}; };
......
...@@ -334,21 +334,19 @@ class media_videojs_plugin extends core_media_player_native { ...@@ -334,21 +334,19 @@ class media_videojs_plugin extends core_media_player_native {
*/ */
public function setup($page) { public function setup($page) {
// Load core video JS. // Load dynamic loader. It will scan page for videojs media and load necessary modules.
// Loader will be loaded on absolutely every page, however the videojs will only be loaded
// when video is present on the page or added later to it in AJAX.
$path = new moodle_url('/media/player/videojs/videojs/video-js.swf'); $path = new moodle_url('/media/player/videojs/videojs/video-js.swf');
$contents = 'videojs.options.flash.swf = "' . $path . '";' . "\n"; $contents = 'videojs.options.flash.swf = "' . $path . '";' . "\n";
$contents .= $this->find_language(current_language()); $contents .= $this->find_language(current_language());
$page->requires->js_amd_inline(<<<EOT $page->requires->js_amd_inline(<<<EOT
require(["media_videojs/video"], function(videojs) { require(["media_videojs/loader"], function(loader) {
$contents loader.setUp(function(videojs) {
$contents
});
}); });
EOT EOT
); );
// Load Youtube JS.
$page->requires->js_amd_inline('require(["media_videojs/Youtube"])');
// Load dynamic loader.
$page->requires->js_call_amd('media_videojs/loader', 'setUp');
} }
} }
...@@ -5,7 +5,7 @@ https://github.com/videojs/video.js ...@@ -5,7 +5,7 @@ https://github.com/videojs/video.js
Instructions to import VideoJS player into Moodle: Instructions to import VideoJS player into Moodle:
1. Download the latest release from https://github.com/videojs/video.js/releases in a separate directory 1. Download the latest release from https://github.com/videojs/video.js/releases in a separate directory
2. copy 'dist/video.js' into 'amd/src/video.js' 2. copy 'dist/video.js' into 'amd/src/video-lazy.js'
3. copy 'dist/font/' into 'fonts/' folder 3. copy 'dist/font/' into 'fonts/' folder
4. copy 'dist/video-js.css' into 'styles.css' 4. copy 'dist/video-js.css' into 'styles.css'
Replace Replace
...@@ -21,8 +21,8 @@ Instructions to import VideoJS player into Moodle: ...@@ -21,8 +21,8 @@ Instructions to import VideoJS player into Moodle:
Import plugins: Import plugins:
1. Copy https://github.com/videojs/videojs-youtube/blob/master/dist/Youtube.js into 'amd/src/Youtube.js' 1. Copy https://github.com/videojs/videojs-youtube/blob/master/dist/Youtube.js into 'amd/src/Youtube-lazy.js'
In the beginning of the js file replace In the beginning of the js file replace
define(['videojs'] define(['videojs']
with with
define(['media_videojs/video'] define(['media_videojs/video-lazy']
<?xml version="1.0"?> <?xml version="1.0"?>
<libraries> <libraries>
<library> <library>
<location>amd/src</location> <location>amd/src/video-lazy.js</location>
<name>VideoJS</name> <name>VideoJS</name>
<license>Apache</license> <license>Apache</license>
<version>5.12.6</version> <version>5.12.6</version>
<licenseversion></licenseversion> <licenseversion></licenseversion>
</library> </library>
<library>
<location>amd/src/Youtube-lazy.js</location>
<name>YouTube Playback Technology for Video.js</name>
<license>MIT</license>
<version>2.1.1</version>
<licenseversion></licenseversion>
</library>
<library> <library>
<location>videojs</location> <location>videojs</location>
<name>VideoJS support files</name> <name>VideoJS support files</name>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment