-
Notifications
You must be signed in to change notification settings - Fork 400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added basic playlist support #57
base: master
Are you sure you want to change the base?
Conversation
Hi @cternes , i put this into the feature list, if you can provide more detail about this for example: |
@@ -122,6 +156,11 @@ Quintus.Audio = function(Q) { | |||
if (!Q.audio.channels[i]['loop'] && Q.audio.channels[i]['finished'] < now) { | |||
|
|||
Q.audio.channels[i]['channel'].src = Q.asset(s).src; | |||
|
|||
if(typeof callback !== 'undefined') { | |||
Q.audio.channels[i].channel.addEventListener('ended', callback()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks wrong. The callback shouldn't be invoked when passed to the event listener. Also listener should be removed after use. Should look like this:
var endedListener = function(){
Q.audio.channels[i].channel.removeEventListener('ended', endedListener);
callback();
}
Q.audio.channels[i].channel.addEventListener('ended', endedListener);
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. |
Maybe a separate module would be good idea |
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. 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. |
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.