Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

cternes
Copy link

@cternes cternes commented Oct 16, 2013

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 ghost added enhancement and removed enhancement labels Jun 3, 2014
@ghost
Copy link

ghost commented Jun 5, 2014

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

@ghost ghost added the requires discussion label Jun 6, 2014
@@ -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());
Copy link
Contributor

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);

@mpkorstanje
Copy link
Contributor

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
Copy link

ghost commented Jun 17, 2014

Maybe a separate module would be good idea

@mpkorstanje
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants