Hello everyone
Asking a general question on how it's best handled to know if a sound has stopped or not. Right now I'm adding a Window Timer that queries every few ms with SoundStatus() if a sound has stopped or not but I'm questioning if this is is a viable method (it works well enough). But I'm wondering if this can be done with a callback as well (for example if a previous sound has stopped play the next one). Any tips for this?
[Solved] Sound Stop Callback
[Solved] Sound Stop Callback
Last edited by whax on Sun Jan 17, 2021 11:48 pm, edited 1 time in total.
Re: Sound Stop Callback
Code: Select all
Procedure PlaySound2(a, c = 0, b = 100, Callback = #Null)
! var a = v_a;
! var b = v_b;
! var c = v_c;
! // original SB-Code (spider_PlaySound()) with callback-call:
! "undefined" === typeof c && (c = 0);
! "undefined" === typeof b && (b = 100);
! var d, e;
! if (d = spider.sound.objects.Get(a))
! if (c & 2) {
! for (e = 1; 32 > e && d.channels[e]; e++)
! ;
! if (32 > e)
! return a = createjs.Sound.play(d.id, createjs.Sound.INTERRUPT_ANY, 0, 0, c & 1 ? -1 : 0, b / 100),
! d.channels[e] = a,
! a.addEventListener("complete", function(a) {
! d.channels[e] = null
! if (v_callback) v_callback(v_a);
! }),
! e
! } else
! return (a = d.channels[0]) ? (a.setPosition(0),
! a.setVolume(b / 100)) : (a = createjs.Sound.play(d.id, createjs.Sound.INTERRUPT_ANY, 0, 0, c & 1 ? -1 : 0, b / 100),
! d.channels[0] = a,
! a.addEventListener("complete", function(a) {
! d.channels[0] = null
! if (v_callback) v_callback(v_a);
! })),
! 1;
! return 0
EndProcedure
Code: Select all
Procedure YourCallback(Sound)
Debug "Sound " + Sound + " is ready"
EndProcedure
PlaySound2(YourSound, Flags, Volume, @YourCallback())
Re: [Solved] Sound Stop Callback
Hello Peter
Thank you very much, exactly what I was looking for. And thank you for your Leaflet + Tabulator Modules as well :)
Thank you very much, exactly what I was looking for. And thank you for your Leaflet + Tabulator Modules as well :)