Skip to content

Commit

Permalink
@gkatsev fixed captions showing by default in Chrome and Safari. closes
Browse files Browse the repository at this point in the history
  • Loading branch information
gkatsev authored and heff committed Feb 14, 2015
1 parent 4e5c28c commit 52e6768
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ CHANGELOG
* @shoshomiga added a Bulgarian translation ([view](https://github.com/videojs/video.js/pull/1849))
* @ragecub3 added a Turkish translation ([view](https://github.com/videojs/video.js/pull/1853))
* @gkatsev greatly improved text track support and implemented vtt.js as the webvtt parser ([view](https://github.com/videojs/video.js/pull/1749))
* @gkatsev fixed captions showing by default in Chrome and Safari ([view](https://github.com/videojs/video.js/pull/1865))

--------------------

Expand Down
22 changes: 22 additions & 0 deletions src/js/media/html5.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ vjs.Html5 = vjs.MediaTechController.extend({
}
}

if (this['featuresNativeTextTracks']) {
this.on('loadstart', vjs.bind(this, this.hideCaptions));
}

// Determine if native controls should be used
// Our goal should be to get the custom controls on mobile solid everywhere
// so we can remove this all together. Right now this will block custom
Expand Down Expand Up @@ -161,6 +165,24 @@ vjs.Html5.prototype.createEl = function(){
// jenniisawesome = true;
};


vjs.Html5.prototype.hideCaptions = function() {
var tracks = this.el_.textTracks,
track,
i = tracks.length,
kinds = {
'captions': 1,
'subtitles': 1
};

while (i--) {
track = tracks[i];
if (track && track['kind'] in kinds) {
track.mode = 'disabled';
}
}
};

// Make video events trigger player events
// May seem verbose here, but makes other APIs possible.
// Triggers removed using this.off when disposed
Expand Down

0 comments on commit 52e6768

Please sign in to comment.