cykod / Quintus

HTML5 Game Engine
http://html5quintus.com
GNU General Public License v2.0
1.41k stars 401 forks source link

Added basic playlist support #57

Open cternes opened 11 years ago

cternes commented 11 years ago

I've added audio support for a playlist, meaning playing a list of sounds one after another. This could be useful to create a playlist of a game soundtrack.

ghost commented 10 years ago

Hi @cternes , i put this into the feature list, if you can provide more detail about this for example: how to fully use it, and all available options. In the next version if we add it, your name will be put as author of this feature. Thank You :D

mpkorstanje commented 10 years ago

Just tested this.

Play list itself works, but bugs happen when the play list is stopped. Call back to start next song is called on timeout, even when the song has been stopped.

I need this functionality. So I'll probably end up fixing it.

ghost commented 10 years ago

Maybe a separate module would be good idea

mpkorstanje commented 10 years ago

I dunno yet.

Right now the problem I'm trying to solve is that there two different cases that result in the same events.

Case A: Audio is finished, audio triggers audio stopped event / timeout ---> callback is invoked. Case B: Audio is stopped, audio triggers audio stopped event / timeout (minutes after the fact) --> callback is invoked

Right now I'm seeing if I can make use the event system from Q and inform listeners about audio events. 'stopped.audioFilename' and 'finished.audioFileName'.

This looks pretty clean and would allow playlists to be a module more easilly, but I'm worried that it might be slow and overengineerd. It also has the problem that there is no good identity for songs, the same file (name) can be playing on multiple tracks.

The alternative would be to remove callback when a song is stopped, which is simple and fast but ties the play lists strongly to audio.

Still I'm prefering the former. It is more flexible and allows more things to be done with Audio.