From 2a51f0c398b417ef5920c12bd237e26414a406f0 Mon Sep 17 00:00:00 2001 From: Joey Parrish Date: Tue, 19 Nov 2024 13:38:06 -0800 Subject: [PATCH] fix(UI): Fix exception while casting to mismatched player version (#7631) 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 --- ui/chapter_selection.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ui/chapter_selection.js b/ui/chapter_selection.js index 223a07470c..f456cf6039 100644 --- a/ui/chapter_selection.js +++ b/ui/chapter_selection.js @@ -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_;