From 865046e668ceb38113241923590c012a03dea094 Mon Sep 17 00:00:00 2001 From: Bill Thornton Date: Tue, 22 Oct 2024 16:34:25 -0400 Subject: [PATCH] Use async/await when getting playlist --- src/controllers/playback/video/index.js | 27 ++++++++++++++----------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/src/controllers/playback/video/index.js b/src/controllers/playback/video/index.js index 3959a166b5..a662e905a0 100644 --- a/src/controllers/playback/video/index.js +++ b/src/controllers/playback/video/index.js @@ -886,18 +886,21 @@ export default function (view) { } } - function updatePlaylist() { - playbackManager.getPlaylist() - .then(playlist => { - if (playlist && playlist.length > 1) { - const btnPreviousTrack = view.querySelector('.btnPreviousTrack'); - const btnNextTrack = view.querySelector('.btnNextTrack'); - btnPreviousTrack.classList.remove('hide'); - btnNextTrack.classList.remove('hide'); - btnPreviousTrack.disabled = false; - btnNextTrack.disabled = false; - } - }); + async function updatePlaylist() { + try { + const playlist = await playbackManager.getPlaylist(); + + if (playlist && playlist.length > 1) { + const btnPreviousTrack = view.querySelector('.btnPreviousTrack'); + const btnNextTrack = view.querySelector('.btnNextTrack'); + btnPreviousTrack.classList.remove('hide'); + btnNextTrack.classList.remove('hide'); + btnPreviousTrack.disabled = false; + btnNextTrack.disabled = false; + } + } catch (err) { + console.error('[VideoPlayer] failed to get playlist', err); + } } function updateTimeText(elem, ticks, divider) {