Skip to content

Instantly share code, notes, and snippets.

@jefBinomed
Created November 30, 2018 16:18
Show Gist options
  • Save jefBinomed/0c0e52c25205ca94aedd73313589f92f to your computer and use it in GitHub Desktop.
Save jefBinomed/0c0e52c25205ca94aedd73313589f92f to your computer and use it in GitHub Desktop.
2018-countdown-time-management-audio
const timeBeforeLastSongs = 60 * 1000; // 1 Minute
const dropTimeForLastSong = 5 * 1000; // 5 sec
export default {
name: 'countdown',
components: { Galaxy, ScoreList, Timer },
// ...
methods: {
/// ...
timeUpdate(event) {
// If we're in the last song delay, we first drop the sound of current sound before
if (
event.diff < timeBeforeLastSongs &&
event.diff > timeBeforeLastSongs - dropTimeForLastSong
) {
// We simulate a kind of fader to switch to last song
const adjustDiff =
event.diff - (timeBeforeLastSongs - dropTimeForLastSong);
this.audioPlayer.manageVolumeFromPercent(
adjustDiff / dropTimeForLastSong,
);
} else if (event.diff < timeBeforeLastSongs && !this.switchToLastsSongs) {
// When it's time, we switch to last song
this.audioPlayer.switchToLastsSongPlaylist();
this.switchToLastsSongs = true;
} else if (this.audioPlayer) {
// We wait for the last 10 seconds to drop down the volume
this.audioPlayer.manageSoundVolume(event.diff);
}
},
// ...
},
// ...
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment