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

callback after end of sound #66

Closed
malorus opened this issue Aug 1, 2017 · 4 comments
Closed

callback after end of sound #66

malorus opened this issue Aug 1, 2017 · 4 comments
Assignees

Comments

@malorus
Copy link

malorus commented Aug 1, 2017

Hi, me again :)
I just thought it would be a good idea if there would be a listener for the end of a soundfile. I searched in the docu for such a callback but couldn't see anything. There are use-cases, where you want to take some actions after the end of the file has been reached. It would be great to have something like:

let sound = new Pizzicato.Sound('audio.mp3', function () {            
    sound.play();	
    sound.on('end', function() {
        // do some stuff after reaching the end of the file
    });		
});

by the way, I've just found an issue right here about trigger-events at the end of a file. So is a trigger already implemented? I ask as I can't see anything in the official doc.

@alemangui
Copy link
Owner

Hey, actually there is currently an event launched when a sound is over, and it works exactly as you suggested it:

sound.on('end', function() {
});	

There are four events you can listen to: play, pause, stop and end

You can see an example in the Sound test file at tests/Sound.test.js.

I will maintain this issue open until these are documented in the Readme.md file.

@alemangui alemangui self-assigned this Aug 1, 2017
@malorus
Copy link
Author

malorus commented Aug 1, 2017

As I have just discovered, such a callback is already implemented. But as it is not mentioned in the documentation, I thought it is not present. So, for all those ones searching in the future for a callback after the file has finished playing, the above mentioned listener will work:

sound.on('end', function() {
    // do some stuff after reaching the end of the file
});	

@alemangui Hey, thanks for your response mate... it seems we have written at almost the same time. Good to know there are such event-listener as they have practical value...

@malorus malorus closed this as completed Aug 1, 2017
@alemangui
Copy link
Owner

I will keep this open until documentation for all events is added.

@alemangui
Copy link
Owner

Documentation on events added.

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

No branches or pull requests

2 participants