Skip to content

Commit

Permalink
fix(captions): Fixed workflow to prepare captions correctly by removi…
Browse files Browse the repository at this point in the history
…ng assignment of current caption to the first one
  • Loading branch information
rafa8626 committed Dec 10, 2019
1 parent e62163b commit a6aa9bf
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 18 deletions.
14 changes: 6 additions & 8 deletions dist/openplayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -5352,25 +5352,23 @@ var Captions = function () {
value: function _prepareTrack(index, language, trackUrl) {
var _this2 = this;

var defaultTrack = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
var showTrack = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
this.trackUrlList[language] = trackUrl;
this.trackList[index].mode = 'disabled';

if (defaultTrack) {
if (showTrack) {
this["default"] = language;
this.button.classList.add('op-controls__captions--on');
this.button.setAttribute('data-active-captions', language);
this.current = Array.from(this.trackList).filter(function (item) {
return item.language === _this2["default"];
}).pop();
} else {
this.current = this.trackList[0];
}

this._show();
this._show();

if (!this.player.getContainer().classList.contains('op-captions--detected')) {
this.player.getContainer().classList.add('op-captions--detected');
if (!this.player.getContainer().classList.contains('op-captions--detected')) {
this.player.getContainer().classList.add('op-captions--detected');
}
}
}
}, {
Expand Down
2 changes: 1 addition & 1 deletion dist/openplayer.min.js

Large diffs are not rendered by default.

16 changes: 7 additions & 9 deletions src/js/controls/captions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -646,24 +646,22 @@ class Captions implements PlayerComponent {
* @param {number} index
* @param {string} language
* @param {string} trackUrl
* @param {boolean} [defaultTrack=false]
* @param {boolean} [showTrack=false]
* @memberof Captions
*/
private _prepareTrack(index: number, language: string, trackUrl: string, defaultTrack: boolean = false) {
private _prepareTrack(index: number, language: string, trackUrl: string, showTrack: boolean = false) {
this.trackUrlList[language] = trackUrl;
this.trackList[index].mode = 'disabled';
if (defaultTrack) {
if (showTrack) {
this.default = language;
this.button.classList.add('op-controls__captions--on');
this.button.setAttribute('data-active-captions', language);
this.current = Array.from(this.trackList)
.filter(item => item.language === this.default).pop();
} else {
this.current = this.trackList[0];
}
this._show();
if (!this.player.getContainer().classList.contains('op-captions--detected')) {
this.player.getContainer().classList.add('op-captions--detected');
this._show();
if (!this.player.getContainer().classList.contains('op-captions--detected')) {
this.player.getContainer().classList.add('op-captions--detected');
}
}
}

Expand Down

0 comments on commit a6aa9bf

Please sign in to comment.