Skip to content

Commit

Permalink
Fix: Fix ARIA label on replay button (shaka-project#3513)
Browse files Browse the repository at this point in the history
  • Loading branch information
Álvaro Velad Galván committed Jul 8, 2021
1 parent bfece76 commit 2dedd9f
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 8 deletions.
10 changes: 10 additions & 0 deletions ui/big_play_button.js
Expand Up @@ -7,6 +7,7 @@

goog.provide('shaka.ui.BigPlayButton');

goog.require('shaka.ui.Locales');
goog.require('shaka.ui.PlayButton');
goog.requireType('shaka.ui.Controls');

Expand Down Expand Up @@ -40,4 +41,13 @@ shaka.ui.BigPlayButton = class extends shaka.ui.PlayButton {
this.button.setAttribute('icon', 'pause');
}
}


/** @override */
updateAriaLabel() {
const LocIds = shaka.ui.Locales.Ids;
const label = this.isPaused() ? LocIds.PLAY : LocIds.PAUSE;

this.button.ariaLabel = this.localization.resolve(label);
}
};
1 change: 1 addition & 0 deletions ui/locales/en.json
Expand Up @@ -27,6 +27,7 @@
"PICTURE_IN_PICTURE": "Picture-in-Picture",
"PLAY": "Play",
"PLAYBACK_RATE": "Playback speed",
"REPLAY": "Replay",
"RESOLUTION": "Resolution",
"REWIND": "Rewind",
"SEEK": "Seek",
Expand Down
4 changes: 4 additions & 0 deletions ui/locales/source.json
Expand Up @@ -113,6 +113,10 @@
"message": "Playback speed",
"description": "Label for a button used to navigate to a submenu to choose the playback speed in the video player."
},
"REPLAY": {
"description": "Label for a button used to replay the video in a video player.",
"message": "Replay"
},
"RESOLUTION": {
"description": "Label for a button used to open a submenu to choose a video resolution in the video player.",
"meaning": "Visual quality",
Expand Down
13 changes: 5 additions & 8 deletions ui/play_button.js
Expand Up @@ -9,7 +9,6 @@ goog.provide('shaka.ui.PlayButton');

goog.require('shaka.ads.AdManager');
goog.require('shaka.ui.Element');
goog.require('shaka.ui.Locales');
goog.require('shaka.ui.Localization');
goog.require('shaka.util.Dom');
goog.requireType('shaka.ui.Controls');
Expand Down Expand Up @@ -95,13 +94,11 @@ shaka.ui.PlayButton = class extends shaka.ui.Element {
return this.controls.presentationIsPaused();
}

/** @protected */
updateAriaLabel() {
const LocIds = shaka.ui.Locales.Ids;
const label = this.isPaused() ? LocIds.PLAY : LocIds.PAUSE;

this.button.ariaLabel = this.localization.resolve(label);
}
/**
* Called when the button's aria label needs to change.
* To be overridden by subclasses.
*/
updateAriaLabel() {}

/**
* Called when the button's icon needs to change.
Expand Down
12 changes: 12 additions & 0 deletions ui/small_play_button.js
Expand Up @@ -9,6 +9,7 @@ goog.provide('shaka.ui.SmallPlayButton');

goog.require('shaka.ui.Controls');
goog.require('shaka.ui.Enums');
goog.require('shaka.ui.Locales');
goog.require('shaka.ui.PlayButton');


Expand Down Expand Up @@ -42,6 +43,17 @@ shaka.ui.SmallPlayButton = class extends shaka.ui.PlayButton {
this.button.textContent = this.isPaused() ? Icons.PLAY : Icons.PAUSE;
}
}

/** @override */
updateAriaLabel() {
const LocIds = shaka.ui.Locales.Ids;
if (this.video.ended) {
this.button.ariaLabel = this.localization.resolve(LocIds.REPLAY);
} else {
const label = this.isPaused() ? LocIds.PLAY : LocIds.PAUSE;
this.button.ariaLabel = this.localization.resolve(label);
}
}
};


Expand Down

0 comments on commit 2dedd9f

Please sign in to comment.