1
0
mirror of https://github.com/videojs/video.js.git synced 2025-07-15 01:34:23 +02:00

Refactored tracks to better match HTML5 spec

This commit is contained in:
Steve Heffernan
2012-03-09 17:12:38 -08:00
parent 12816b8409
commit aeecc92194
7 changed files with 570 additions and 187 deletions

75
src/controls.js vendored
View File

@ -783,79 +783,4 @@ _V_.Poster = _V_.Button.extend({
onClick: function(){
this.player.play();
}
});
/* Text Track Displays
================================================================================ */
// Create a behavior type for each text track type (subtitlesDisplay, captionsDisplay, etc.).
// Then you can easily do something like.
// player.addBehavior(myDiv, "subtitlesDisplay");
// And the myDiv's content will be updated with the text change.
// Base class for all track displays. Should not be instantiated on its own.
_V_.TextTrackDisplay = _V_.Component.extend({
init: function(player, options){
this._super(player, options);
player.addEvent(this.trackType + "update", _V_.proxy(this, this.update));
},
createElement: function(){
return this._super("div", {
className: "vjs-" + this.trackType + " vjs-text-track"
});
},
update: function(){
this.el.innerHTML = this.player.textTrackValue(this.trackType);
}
});
_V_.SubtitlesDisplay = _V_.TextTrackDisplay.extend({
trackType: "subtitles"
});
_V_.CaptionsDisplay = _V_.TextTrackDisplay.extend({
trackType: "captions"
});
_V_.ChaptersDisplay = _V_.TextTrackDisplay.extend({
trackType: "chapters"
});
_V_.DescriptionsDisplay = _V_.TextTrackDisplay.extend({
trackType: "descriptions"
});
/* Captions Button
================================================================================ */
_V_.CaptionsButton = _V_.Button.extend({
buttonText: "Captions",
buildCSSClass: function(){
return "vjs-captions-control " + this._super();
},
onClick: function(){
this.player.textTrackValue("captions", "Hi<br>hi2")
var captionsDisplay = this.player.captionsDisplay;
if (captionsDisplay.el.style.display == "block") {
captionsDisplay.hide();
} else {
captionsDisplay.show();
}
}
});