braingdx
braingdx copied to clipboard
Introduce music playlists
Motivation
It is currently very cumbersome to define music playing in a screen. In order to do that you need to start the music, set it to looping and make sure that it fades out before the screen exits, otherwise it is going to continue at the end of a screen.
⭐ Design
// loop through the following music tracks, also fade it out
// when the screen either exits or fades out
// this should be the default behavior.
context.getAudioManager().loopMusic(Musics.SONG_1, Musics.SONG_2, true);
Requirements
- overload
AudioManager
methods to accept asset ids - calling
loopMusic
should stop all other currently playing music - when looping method, it should loop from left to right (no shuffle play mode for now)
- when the screen is faded out with
ScreenTransitions
use the same fade out interval to fade out the music - when the screen is simply changed, stop the music instead