Use async/await when getting playlist

This commit is contained in:
Bill Thornton 2024-10-22 16:34:25 -04:00
parent a2e0f52297
commit 865046e668

View File

@ -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) {