Skip to content

Commit

Permalink
Add a 'loadeddata' event on TextTracks, which fixes issue videojs#1864.
Browse files Browse the repository at this point in the history
  • Loading branch information
OwenEdwards committed Mar 13, 2015
1 parent ab84de6 commit 0b65aa6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
25 changes: 12 additions & 13 deletions src/js/tracks/text-track-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,24 +488,23 @@ vjs.ChaptersButton.prototype.createMenu = function(){
track, chaptersTrack,
items = this.items = [];

//TODO: Handle more than one chapters track
for (; i < l; i++) {
track = tracks[i];
if (track['kind'] == this.kind_) {
if (!track.cues) {
track['mode'] = 'hidden';
/* jshint loopfunc:true */
// TODO see if we can figure out a better way of doing this https://github.com/videojs/video.js/issues/1864
window.setTimeout(vjs.bind(this, function() {
this.createMenu();
}), 100);
/* jshint loopfunc:false */
} else {
chaptersTrack = track;
break;
}
chaptersTrack = track;
break;
}
}

if (chaptersTrack && !chaptersTrack.cues) {
chaptersTrack['mode'] = 'hidden';

chaptersTrack.addEventListener('loadeddata', vjs.bind(this, function() {
this.update();
}));
}

var menu = this.menu;
if (menu === undefined) {
menu = new vjs.Menu(this.player_);
Expand All @@ -516,7 +515,7 @@ vjs.ChaptersButton.prototype.createMenu = function(){
}));
}

if (chaptersTrack) {
if (chaptersTrack && chaptersTrack.cues) {
var cues = chaptersTrack['cues'], cue, mi;
i = 0;
l = cues.length;
Expand Down
3 changes: 3 additions & 0 deletions src/js/tracks/text-track.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,9 +186,11 @@ vjs.TextTrack.prototype = vjs.obj.create(vjs.EventEmitter.prototype);
vjs.TextTrack.prototype.constructor = vjs.TextTrack;

/*
* loadeddata - The text track was downloaded and parsed
* cuechange - One or more cues in the track have become active or stopped being active.
*/
vjs.TextTrack.prototype.allowedEvents_ = {
'loadeddata': 'loadeddata',
'cuechange': 'cuechange'
};

Expand Down Expand Up @@ -241,6 +243,7 @@ loadTrack = function(src, track) {

track.loaded_ = true;
parseCues(responseBody, track);
track.trigger('loadeddata');
}));
};

Expand Down

0 comments on commit 0b65aa6

Please sign in to comment.