How do i setup a "finished playing" callback

24 views
Skip to first unread message

Aaron McLeod

unread,
Jun 1, 2014, 11:41:53 AM6/1/14
to mel...@googlegroups.com
I Know we had like a gagillion chat messages around callbacks, but my memory is kinda terrible. How do i setup a callback when a sound finishes playing? Setting up a music cycle for a game.

The callback when you pass it to me.audio.play() gets executed when the sound starts playing, and gets bound to the on('end'). Though i wasnt sure how it gets bound to our callbacks hash based on sound ids.

https://github.com/melonjs/melonJS/blob/d71cef663728434400282c85229493368a72c652/src/audio/audio.js#L149

--
Aaron McLeod
http://agmprojects.com

Jay Oster

unread,
Jun 1, 2014, 2:34:02 PM6/1/14
to mel...@googlegroups.com
As far as I can tell, this is a new bug. The callback was inappropriately removed here: https://github.com/melonjs/melonJS/commit/397a1347acb662134a6ecd9f107763b8e66ee61b#diff-0ee9ee23551e9c51cdda33fcb8540c2dL192

Jay Oster

unread,
Jun 1, 2014, 3:33:53 PM6/1/14
to mel...@googlegroups.com
Ticket is here: https://github.com/melonjs/melonJS/issues/515 I've included a workaround function in the ticket for 1.0.x, and recommend fixing it properly for 1.1.x

Aaron McLeod

unread,
Jun 1, 2014, 3:35:52 PM6/1/14
to mel...@googlegroups.com
Cool. Yeah i wasn't sure if the soundId system we have in place would be enough for managing a callback with each individual sound.


--
You received this message because you are subscribed to the Google Groups "melonJS - A lightweight HTML5 game engine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to melonjs+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Jay Oster

unread,
Jun 1, 2014, 3:42:27 PM6/1/14
to mel...@googlegroups.com
It is. But the code to add to the list of callbacks was removed by accident. ;(

Aaron McLeod

unread,
Jun 1, 2014, 3:43:27 PM6/1/14
to mel...@googlegroups.com
Ah crud lol. Might take a look at it in a bit.

Jay Oster

unread,
Jun 1, 2014, 3:48:20 PM6/1/14
to mel...@googlegroups.com
No worries, It's very very simple, and I already know exactly what's needed. I'll do it.

Aaron McLeod

unread,
Jun 1, 2014, 4:41:44 PM6/1/14
to mel...@googlegroups.com
Ah okay, cool :)
Reply all
Reply to author
Forward
0 new messages