Skip to content

Commit

Permalink
fix(UI): Fix replay button when the post-roll is running using CS (#6072
Browse files Browse the repository at this point in the history
)
  • Loading branch information
avelad committed Jan 10, 2024
1 parent 44cb8a2 commit 6b7a02a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
17 changes: 17 additions & 0 deletions ui/play_button.js
Expand Up @@ -72,6 +72,11 @@ shaka.ui.PlayButton = class extends shaka.ui.Element {
this.updateIcon();
});

this.eventManager.listen(this.adManager, AdManager.AD_STOPPED, () => {
this.updateAriaLabel();
this.updateIcon();
});

this.eventManager.listen(this.button, 'click', () => {
if (this.ad && this.ad.isLinear()) {
this.controls.playPauseAd();
Expand Down Expand Up @@ -99,6 +104,18 @@ shaka.ui.PlayButton = class extends shaka.ui.Element {
return this.controls.presentationIsPaused();
}

/**
* @return {boolean}
* @protected
*/
isEnded() {
if (this.ad && this.ad.isLinear()) {
return false;
}

return this.video.ended;
}

/**
* Called when the button's aria label needs to change.
* To be overridden by subclasses.
Expand Down
4 changes: 2 additions & 2 deletions ui/small_play_button.js
Expand Up @@ -38,7 +38,7 @@ shaka.ui.SmallPlayButton = class extends shaka.ui.PlayButton {
/** @override */
updateIcon() {
const Icons = shaka.ui.Enums.MaterialDesignIcons;
if (this.video.ended) {
if (this.isEnded()) {
this.button.textContent = Icons.REPLAY;
} else {
this.button.textContent = this.isPaused() ? Icons.PLAY : Icons.PAUSE;
Expand All @@ -48,7 +48,7 @@ shaka.ui.SmallPlayButton = class extends shaka.ui.PlayButton {
/** @override */
updateAriaLabel() {
const LocIds = shaka.ui.Locales.Ids;
if (this.video.ended) {
if (this.isEnded()) {
this.button.ariaLabel = this.localization.resolve(LocIds.REPLAY);
} else {
const label = this.isPaused() ? LocIds.PLAY : LocIds.PAUSE;
Expand Down

0 comments on commit 6b7a02a

Please sign in to comment.