1
0
mirror of https://github.com/videojs/video.js.git synced 2024-11-24 08:42:25 +02:00

@mister-ben fixed missing native HTML5 tracks. Fixes #2689. Closes #3212

This commit is contained in:
mister-ben 2016-03-29 17:19:59 -04:00 committed by Gary Katsevman
parent b2d0e10dbd
commit a22c7f2a4d
3 changed files with 23 additions and 10 deletions

View File

@ -5,6 +5,7 @@ CHANGELOG
* @llun fixed menus from throwing when focused when empty ([view](https://github.com/videojs/video.js/pull/3218))
* @mister-ben added dir=ltr to control bar and loading spinner ([view](https://github.com/videojs/video.js/pull/3221))
* @avreg fixed notSupportedMessage saying video when meaning media ([view](https://github.com/videojs/video.js/pull/3222))
* @mister-ben fixed missing native HTML5 tracks ([view](https://github.com/videojs/video.js/pull/3212))
--------------------

View File

@ -257,10 +257,18 @@ class Html5 extends Tech {
proxyNativeTextTracks_() {
let tt = this.el().textTracks;
if (tt && tt.addEventListener) {
tt.addEventListener('change', this.handleTextTrackChange_);
tt.addEventListener('addtrack', this.handleTextTrackAdd_);
tt.addEventListener('removetrack', this.handleTextTrackRemove_);
if (tt) {
// Add tracks - if player is initialised after DOM loaded, textTracks
// will not trigger addtrack
for (let i = 0; i < tt.length; i++) {
this.textTracks().addTrack_(tt[i]);
}
if (tt.addEventListener) {
tt.addEventListener('change', this.handleTextTrackChange_);
tt.addEventListener('addtrack', this.handleTextTrackAdd_);
tt.addEventListener('removetrack', this.handleTextTrackRemove_);
}
}
}
@ -504,7 +512,7 @@ class Html5 extends Tech {
* @return {Object}
* @method currentSrc
*/
currentSrc() {
currentSrc() {
if (this.currentSource_) {
return this.currentSource_.src;
} else {

View File

@ -78,12 +78,16 @@ class TextTrackList extends EventTarget {
track.addEventListener('modechange', Fn.bind(this, function() {
this.trigger('change');
}));
this.tracks_.push(track);
this.trigger({
track,
type: 'addtrack'
});
// Do not add duplicate tracks
if (this.tracks_.indexOf(track) === -1) {
this.tracks_.push(track);
this.trigger({
track,
type: 'addtrack'
});
}
}
/**