Skip to content

Commit

Permalink
video.jsのバージョンアップ
Browse files Browse the repository at this point in the history
  • Loading branch information
Takayuki Fuwa committed Aug 21, 2016
1 parent 64a30c1 commit b58f22b
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 2 deletions.
21 changes: 20 additions & 1 deletion classes/html_writer.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ public static function video($url, $params, $enable_autoload, $enable_controls)

$js = <<<JS
videojs.options.flash.swf = "js/video-js.swf";
//videojs.flashls({swfUrl: "js/video-js.swf"});
videojs.options.flash.swf = "video-js.swf";
var player = videojs("simplevideo_player", {
controls: $enable_controls,
autoplay: $enable_autoload,
Expand All @@ -56,9 +58,26 @@ public static function video($url, $params, $enable_autoload, $enable_controls)
"width": 640,
"height": 480,
plugins: {},
hls: {withCredentials: false},
flash : {
hls: {
withCredentials: false
}
},
html5 : {
hls: {
withCredentials: false
}
}
});
player.src({
src: "$url",
type: 'application/x-mpegURL',
withCredentials: false
});
JS;
$html .= html_writer::script($js, null);

Expand Down
Binary file modified js/video-js.swf
Binary file not shown.
42 changes: 42 additions & 0 deletions js/videojs.flashls.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
(function(window, videojs, undefined){
'use strict';

videojs.flashls = function(options){
options = options || {};

// set the swf url to the flashls fork of video-js.swf
// to download the forked swf, go here: https://github.com/mangui/video-js-swf
if(options.swfUrl){
videojs.options.flash.swf = options.swfUrl;
}

videojs.options.flash.flashVars = videojs.options.flash.flashVars || {};

// v0.4.1.1 of mangui/video-js.swf is broken when capleveltostage=true, where it only plays the first level in the
// playlist regardless of the bandwidth it can handle, so we set capleveltostage=false.
// more info can be found here: https://github.com/mangui/flashls/issues/351
videojs.options.flash.flashVars.hls_capleveltostage = false;

// with v0.4.1.1 the seeking would jump pretty far back, so switching the mode to be more accurate versus using
// the closest keyframe
videojs.options.flash.flashVars.hls_seekmode = "ACCURATE";

// we need to set "flash" as a higher priority tech than "html5", so that when
// videojs boots up, it tries to handle the m3u8 source with the flash handler
videojs.options.techOrder = ['flash','html5'];

// register a source handler for m3u8 files, so that videojs knows the flashls' video-js.swf
// can handle playing m3u8 files.
videojs.Flash.registerSourceHandler({
canHandleSource: function(source){
return source.type === 'application/x-mpegURL' ? 'maybe' : '';
},
handleSource: function(source, tech){
tech.setSrc(source.src);
}
});

return videojs;
};

})(window, window.videojs, document);
Binary file added video-js.swf
Binary file not shown.
5 changes: 4 additions & 1 deletion view.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@
$PAGE->requires->css(new \moodle_url("css/video-js.min.css"));
$PAGE->requires->js(new \moodle_url("js/video.min.js"), true);
//$PAGE->requires->js(new \moodle_url("js/videojs-contrib-media-sources.min.js"), true);
//$PAGE->requires->js(new \moodle_url("js/videojs.flashls.js"), true);
$PAGE->requires->js(new \moodle_url("js/videojs-contrib-hls.min.js"), true);
//$PAGE->requires->js(new \moodle_url("js/video_main.js"));

echo $OUTPUT->header();

Expand All @@ -87,7 +89,8 @@
"id" => "simplevideo_player",
"class" => "video-js vjs-default-skin vjs-big-play-centered",
"data-setup" => '{
"playbackRates": [0.5, 1, 1.5, 2]
"playbackRates": [0.5, 1, 1.5, 2],
"techOrder": ["flash", "html5"]
}'
];
echo html_writer::start_div("span7 well");
Expand Down

0 comments on commit b58f22b

Please sign in to comment.