Skip to content

Commit

Permalink
fix(UI): Fix exception while casting to mismatched player version (#7631
Browse files Browse the repository at this point in the history
)

If the remote player does not have getChapters(), the proxied call returns undefined.  This led to exceptions when .length was accessed.

Reported as part of issue #7546
  • Loading branch information
joeyparrish authored Nov 19, 2024
1 parent 9e2b15e commit c9534a0
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ui/chapter_selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,18 @@ shaka.ui.ChapterSelection = class extends shaka.ui.SettingsMenu {
const currentLocales = this.localization.getCurrentLocales();
for (const locale of Array.from(currentLocales)) {
nextLanguage = locale;
nextChapters = this.player.getChapters(nextLanguage);
// If player is a proxy, and the cast receiver doesn't support this
// method, you get back undefined.
nextChapters = this.player.getChapters(nextLanguage) || [];
if (nextChapters.length) {
break;
}
}
if (!nextChapters.length) {
nextLanguage = 'und';
nextChapters = this.player.getChapters(nextLanguage);
// If player is a proxy, and the cast receiver doesn't support this
// method, you get back undefined.
nextChapters = this.player.getChapters(nextLanguage) || [];
}

const languageChanged = nextLanguage !== this.chaptersLanguage_;
Expand Down

0 comments on commit c9534a0

Please sign in to comment.