I have written a script that, when the button is clicked, the volume is slowly lowered and then the player plays the next song and brings the voluma back to its previous level.
Code: Select all
const volumeToSet = 0
const durationToSet = 3 // 3 secs to lower the volume to 'volumeToSet' and start next track
const stepDuration = 0.050 // 50 ms between steps
if(app.player.isPlaying){
initialVolume = app.player.volume;
volumeStep = initialVolume / (durationToSet / stepDuration)
actualVolume = app.player.volume;
let timerId = setInterval(() => {
if(actualVolume > 0){
actualVolume = Math.max((actualVolume - volumeStep), 0)
app.player.volume = actualVolume
console.log(actualVolume)
//console.log(actualVolume)
}else{
// app.player.stopAsync();
clearInterval(timerId);
app.player.nextAsync(); // pasa al proximo tema
app.player.volume = initialVolume; // devuelve el volumen al valor anterior
}
}, (stepDuration * 1000));
}else{
app.player.nextAsync(); // pasa DIRECTAMENTE al proximo tema
}
I'll be happy to hear your suggestions.
Thanks,
Marcelo