From 7f099eef4e0cb2fd98bd958a57cc2ba2bcc643c3 Mon Sep 17 00:00:00 2001 From: TC Date: Mon, 6 Feb 2023 23:21:12 +0100 Subject: [PATCH] Track transitioning status --- plugins/crossfade/front.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/plugins/crossfade/front.js b/plugins/crossfade/front.js index c286fb25..433f5c19 100644 --- a/plugins/crossfade/front.js +++ b/plugins/crossfade/front.js @@ -6,6 +6,7 @@ require("./fader"); let transitionAudio; // Howler audio used to fade out the current music let firstVideo = true; +let transitioning = false; // Crossfade options that can be overridden in plugin options let crossfadeOptions = { @@ -108,8 +109,10 @@ const syncVideoWithTransitionAudio = async () => { const onApiLoaded = () => { watchVideoIDChanges(async (videoID) => { - const url = await getStreamURL(videoID); - await createAudioForCrossfade(url); + if (!transitioning) { + const url = await getStreamURL(videoID); + await createAudioForCrossfade(url); + } }); }; @@ -118,6 +121,7 @@ const crossfade = (cb) => { cb(); return; } + transitioning = true; const video = document.querySelector("video"); @@ -129,7 +133,10 @@ const crossfade = (cb) => { // Fade out the music video.volume = 0; - fader.fadeOut(cb); + fader.fadeOut(() => { + transitioning = false; + cb(); + }); }; module.exports = (options) => {