Skip to content

Commit

Permalink
Fixed the default flag for captions/subtitles tracks. closes #1153 cl…
Browse files Browse the repository at this point in the history
…oses #656
  • Loading branch information
Chris Fung authored and heff committed May 7, 2014
1 parent dbff62e commit 1df28ff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
12 changes: 9 additions & 3 deletions src/js/tracks.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,15 @@ vjs.Player.prototype.addTextTrack = function(kind, label, language, options){
// TODO: Add a process to deterime the best track to show for the specific kind
// Incase there are mulitple defaulted tracks of the same kind
// Or the user has a set preference of a specific language that should override the default
// if (track.dflt()) {
// this.ready(vjs.bind(track, track.show));
// }
// Note: The setTimeout is a workaround because with the html5 tech, the player is 'ready'
// before it's child components (including the textTrackDisplay) have finished loading.
if (track.dflt()) {
this.ready(function(){
setTimeout(function(){
track.show();
}, 0);
});
}

return track;
};
Expand Down
4 changes: 2 additions & 2 deletions test/unit/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ test('should get tag, source, and track settings', function(){
var html = '<video id="example_1" class="video-js" autoplay preload="metadata">';
html += '<source src="http://google.com" type="video/mp4">';
html += '<source src="http://google.com" type="video/webm">';
html += '<track src="http://google.com" kind="captions" default>';
html += '<track src="http://google.com" kind="captions" attrtest>';
html += '</video>';

fixture.innerHTML += html;
Expand All @@ -97,7 +97,7 @@ test('should get tag, source, and track settings', function(){
ok(player.options_['sources'][1].type === 'video/webm');
ok(player.options_['tracks'].length === 1);
ok(player.options_['tracks'][0]['kind'] === 'captions'); // No extern
ok(player.options_['tracks'][0]['default'] === true);
ok(player.options_['tracks'][0]['attrtest'] === '');

ok(player.el().className.indexOf('video-js') !== -1, 'transferred class from tag to player div');
ok(player.el().id === 'example_1', 'transferred id from tag to player div');
Expand Down

0 comments on commit 1df28ff

Please sign in to comment.