Skip to content

Commit

Permalink
fix(player): Moved checking of captions inside create method to all…
Browse files Browse the repository at this point in the history
…ow re-checking of them when recreating controls; fixed documentation
  • Loading branch information
rafa8626 committed Feb 16, 2022
1 parent 136df4b commit 05fc5fc
Show file tree
Hide file tree
Showing 14 changed files with 151 additions and 125 deletions.
58 changes: 29 additions & 29 deletions CHANGELOG.md

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# Contributing guidelines

We appreciate the time you are spending to contribute to this project! 🙌

In order to have your pull request merged successfully, keep in mind the following key points:
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ So, please consider this before upgrading to any of the 3.x.x version going forw

| | | |
|--|--|--|
|[<img width="120" alt="MedSims" src="https://img.medscapestatic.com/pi/global/icons/icon-medsims-logo@2x.png" />](https://www.medscape.org/simulation) | [<img width="120" alt="Arrow Classic Rock" src="https://player.arrow.nl/tmp/images/logo.1507670326.jpg" />](https://player.arrow.nl/ad.html) | [<img width="120" alt="Uttlesford District Council" src="https://uttlesford.moderngov.co.uk/SiteSpecific/res/img/uttlesfordlogo.png" />](https://uttlesford.moderngov.co.uk/ieListDocuments.aspx?CId=159&MId=5501)|
|[<img width="120" alt="LectureTube" src="https://live.video.tuwien.ac.at/room/assets/lecturetube_landscape.svg" />](https://live.video.tuwien.ac.at/room/heart0/player.html)| [Servicio Online](https://40152354.servicio-online.net//INDEX.html)| |
|[![MedSims](https://img.medscapestatic.com/pi/global/icons/icon-medsims-logo@2x.png)](https://www.medscape.org/simulation) | [![Arrow Classic Rock](https://player.arrow.nl/tmp/images/logo.1507670326.jpg)](https://player.arrow.nl/ad.html) | [![Uttlesford District Council](https://uttlesford.moderngov.co.uk/SiteSpecific/res/img/uttlesfordlogo.png)](https://uttlesford.moderngov.co.uk/ieListDocuments.aspx?CId=159&MId=5501)|
|[![LectureTube](https://live.video.tuwien.ac.at/room/assets/lecturetube_landscape.svg)](https://live.video.tuwien.ac.at/room/heart0/player.html)| [Servicio Online](https://40152354.servicio-online.net//INDEX.html)| |

## Migrating from older version to new ones

Expand Down
27 changes: 14 additions & 13 deletions dist/esm/controls/captions.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,16 @@ class Captions {
__classPrivateFieldSet(this, _Captions_player, player, "f");
__classPrivateFieldSet(this, _Captions_controlPosition, position, "f");
__classPrivateFieldSet(this, _Captions_controlLayer, layer, "f");
this._getCuesFromText = this._getCuesFromText.bind(this);
this._getNativeCues = this._getNativeCues.bind(this);
this._displayCaptions = this._displayCaptions.bind(this);
this._hideCaptions = this._hideCaptions.bind(this);
this._search = this._search.bind(this);
this._prepareTrack = this._prepareTrack.bind(this);
this._formatMenuItems = this._formatMenuItems.bind(this);
return this;
}
create() {
const trackList = __classPrivateFieldGet(this, _Captions_player, "f").getElement().textTracks;
const tracks = [];
for (let i = 0, total = trackList.length; i < total; i++) {
Expand All @@ -54,9 +64,6 @@ class Captions {
}
__classPrivateFieldSet(this, _Captions_mediaTrackList, tracks, "f");
__classPrivateFieldSet(this, _Captions_hasTracks, !!__classPrivateFieldGet(this, _Captions_mediaTrackList, "f").length, "f");
return this;
}
create() {
if (!__classPrivateFieldGet(this, _Captions_hasTracks, "f")) {
return;
}
Expand All @@ -80,8 +87,8 @@ class Captions {
</div>
</div>`;
}
for (let i = 0, tracks = __classPrivateFieldGet(this, _Captions_player, "f").getElement().querySelectorAll('track'), total = tracks.length; i < total; i++) {
const element = tracks[i];
for (let i = 0, trackItems = __classPrivateFieldGet(this, _Captions_player, "f").getElement().querySelectorAll('track'), total = trackItems.length; i < total; i++) {
const element = trackItems[i];
if (element.kind === 'subtitles' || element.kind === 'captions') {
if (element.default) {
__classPrivateFieldSet(this, _Captions_default, element.srclang, "f");
Expand Down Expand Up @@ -218,16 +225,10 @@ class Captions {
itemContainer.className = `op-controls__container op-control__${__classPrivateFieldGet(this, _Captions_controlPosition, "f")}`;
itemContainer.appendChild(__classPrivateFieldGet(this, _Captions_button, "f"));
itemContainer.appendChild(__classPrivateFieldGet(this, _Captions_menu, "f"));
__classPrivateFieldGet(this, _Captions_player, "f")
.getControls()
.getLayer(__classPrivateFieldGet(this, _Captions_controlLayer, "f"))
.appendChild(itemContainer);
__classPrivateFieldGet(this, _Captions_player, "f").getControls().getLayer(__classPrivateFieldGet(this, _Captions_controlLayer, "f")).appendChild(itemContainer);
}
else {
__classPrivateFieldGet(this, _Captions_player, "f")
.getControls()
.getLayer(__classPrivateFieldGet(this, _Captions_controlLayer, "f"))
.appendChild(__classPrivateFieldGet(this, _Captions_button, "f"));
__classPrivateFieldGet(this, _Captions_player, "f").getControls().getLayer(__classPrivateFieldGet(this, _Captions_controlLayer, "f")).appendChild(__classPrivateFieldGet(this, _Captions_button, "f"));
}
__classPrivateFieldGet(this, _Captions_button, "f").addEventListener('click', __classPrivateFieldGet(this, _Captions_events, "f").button.click, EVENT_OPTIONS);
}
Expand Down
23 changes: 11 additions & 12 deletions dist/esm/controls/play.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class Play {
return this;
}
create() {
var _a;
const { labels } = __classPrivateFieldGet(this, _Play_player, "f").getOptions();
__classPrivateFieldSet(this, _Play_button, document.createElement('button'), "f");
__classPrivateFieldGet(this, _Play_button, "f").type = 'button';
Expand All @@ -39,10 +40,7 @@ class Play {
__classPrivateFieldGet(this, _Play_button, "f").setAttribute('aria-controls', __classPrivateFieldGet(this, _Play_player, "f").id);
__classPrivateFieldGet(this, _Play_button, "f").setAttribute('aria-pressed', 'false');
__classPrivateFieldGet(this, _Play_button, "f").setAttribute('aria-label', (labels === null || labels === void 0 ? void 0 : labels.play) || '');
__classPrivateFieldGet(this, _Play_player, "f")
.getControls()
.getLayer(__classPrivateFieldGet(this, _Play_controlLayer, "f"))
.appendChild(__classPrivateFieldGet(this, _Play_button, "f"));
__classPrivateFieldGet(this, _Play_player, "f").getControls().getLayer(__classPrivateFieldGet(this, _Play_controlLayer, "f")).appendChild(__classPrivateFieldGet(this, _Play_button, "f"));
__classPrivateFieldGet(this, _Play_events, "f").button = (e) => {
__classPrivateFieldGet(this, _Play_button, "f").setAttribute('aria-pressed', 'true');
const el = __classPrivateFieldGet(this, _Play_player, "f").activeElement();
Expand Down Expand Up @@ -148,21 +146,22 @@ class Play {
Object.keys(__classPrivateFieldGet(this, _Play_events, "f").media).forEach((event) => {
element.addEventListener(event, __classPrivateFieldGet(this, _Play_events, "f").media[event], EVENT_OPTIONS);
});
__classPrivateFieldGet(this, _Play_player, "f")
.getControls()
.getContainer()
.addEventListener('controlschanged', __classPrivateFieldGet(this, _Play_events, "f").controls.controlschanged, EVENT_OPTIONS);
if ((_a = __classPrivateFieldGet(this, _Play_player, "f").getOptions().media) === null || _a === void 0 ? void 0 : _a.pauseOnClick) {
element.addEventListener('click', __classPrivateFieldGet(this, _Play_events, "f").button, EVENT_OPTIONS);
}
__classPrivateFieldGet(this, _Play_player, "f").getControls().getContainer().addEventListener('controlschanged', __classPrivateFieldGet(this, _Play_events, "f").controls.controlschanged, EVENT_OPTIONS);
__classPrivateFieldGet(this, _Play_player, "f").getContainer().addEventListener('keydown', this._enterSpaceKeyEvent, EVENT_OPTIONS);
__classPrivateFieldGet(this, _Play_button, "f").addEventListener('click', __classPrivateFieldGet(this, _Play_events, "f").button, EVENT_OPTIONS);
}
destroy() {
var _a;
Object.keys(__classPrivateFieldGet(this, _Play_events, "f").media).forEach((event) => {
__classPrivateFieldGet(this, _Play_player, "f").getElement().removeEventListener(event, __classPrivateFieldGet(this, _Play_events, "f").media[event]);
});
__classPrivateFieldGet(this, _Play_player, "f")
.getControls()
.getContainer()
.removeEventListener('controlschanged', __classPrivateFieldGet(this, _Play_events, "f").controls.controlschanged);
if ((_a = __classPrivateFieldGet(this, _Play_player, "f").getOptions().media) === null || _a === void 0 ? void 0 : _a.pauseOnClick) {
__classPrivateFieldGet(this, _Play_player, "f").getElement().removeEventListener('click', __classPrivateFieldGet(this, _Play_events, "f").button);
}
__classPrivateFieldGet(this, _Play_player, "f").getControls().getContainer().removeEventListener('controlschanged', __classPrivateFieldGet(this, _Play_events, "f").controls.controlschanged);
__classPrivateFieldGet(this, _Play_player, "f").getContainer().removeEventListener('keydown', this._enterSpaceKeyEvent);
__classPrivateFieldGet(this, _Play_button, "f").removeEventListener('click', __classPrivateFieldGet(this, _Play_events, "f").button);
__classPrivateFieldGet(this, _Play_button, "f").remove();
Expand Down
1 change: 0 additions & 1 deletion dist/esm/media/ads.js
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,6 @@ class Ads {
__classPrivateFieldGet(this, _Ads_loader, "f").removeEventListener(google.ima.AdErrorEvent.Type.AD_ERROR, this._error);
__classPrivateFieldGet(this, _Ads_loader, "f").removeEventListener(google.ima.AdsManagerLoadedEvent.Type.ADS_MANAGER_LOADED, this._loaded);
}
console.log(__classPrivateFieldGet(this, _Ads_currentIndex, "f"), __classPrivateFieldGet(this, _Ads_ads, "f").length);
const destroy = !Array.isArray(__classPrivateFieldGet(this, _Ads_ads, "f")) || __classPrivateFieldGet(this, _Ads_currentIndex, "f") > __classPrivateFieldGet(this, _Ads_ads, "f").length;
if (__classPrivateFieldGet(this, _Ads_manager, "f") && destroy) {
__classPrivateFieldGet(this, _Ads_manager, "f").destroy();
Expand Down
3 changes: 3 additions & 0 deletions dist/esm/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ class Player {
showLabel: true,
showProgress: false,
},
media: {
pauseOnClick: false,
},
mode: 'responsive',
onError: (e) => console.error(e),
pauseOthers: true,
Expand Down
Loading

0 comments on commit 05fc5fc

Please sign in to comment.