mirror of
https://github.com/th-ch/youtube-music.git
synced 2026-01-13 03:11:46 +00:00
Track transitioning status
This commit is contained in:
@ -6,6 +6,7 @@ require("./fader");
|
|||||||
|
|
||||||
let transitionAudio; // Howler audio used to fade out the current music
|
let transitionAudio; // Howler audio used to fade out the current music
|
||||||
let firstVideo = true;
|
let firstVideo = true;
|
||||||
|
let transitioning = false;
|
||||||
|
|
||||||
// Crossfade options that can be overridden in plugin options
|
// Crossfade options that can be overridden in plugin options
|
||||||
let crossfadeOptions = {
|
let crossfadeOptions = {
|
||||||
@ -108,8 +109,10 @@ const syncVideoWithTransitionAudio = async () => {
|
|||||||
|
|
||||||
const onApiLoaded = () => {
|
const onApiLoaded = () => {
|
||||||
watchVideoIDChanges(async (videoID) => {
|
watchVideoIDChanges(async (videoID) => {
|
||||||
const url = await getStreamURL(videoID);
|
if (!transitioning) {
|
||||||
await createAudioForCrossfade(url);
|
const url = await getStreamURL(videoID);
|
||||||
|
await createAudioForCrossfade(url);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -118,6 +121,7 @@ const crossfade = (cb) => {
|
|||||||
cb();
|
cb();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
transitioning = true;
|
||||||
|
|
||||||
const video = document.querySelector("video");
|
const video = document.querySelector("video");
|
||||||
|
|
||||||
@ -129,7 +133,10 @@ const crossfade = (cb) => {
|
|||||||
|
|
||||||
// Fade out the music
|
// Fade out the music
|
||||||
video.volume = 0;
|
video.volume = 0;
|
||||||
fader.fadeOut(cb);
|
fader.fadeOut(() => {
|
||||||
|
transitioning = false;
|
||||||
|
cb();
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
module.exports = (options) => {
|
module.exports = (options) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user