Copy link to clipboard
Copied
Hi all...
I'm writing some code that's an audio player; I'm using the streaming API (the SAMPLE_DATA event) to push the audio data.
This works fine, and I get a SOUND_COMPLETE event when there is no more sound data.
However, if I execute the function SoundChannel.stop() (in response to a "pause" button being pressed onscreen), the audio stops, but no SOUND_COMPLETE event is generated.
Is this as expected? It seems odd to me that a SOUND_COMPLETE event would only be generated when incoming sound data is exhausted, but not when the stop() method is called.
Does anyone have experience with these APs? I couldn't find a solution anywhere I've searched so far...
- Tim
actually, i don't see a satisfactory way to do that because the soundchannel class is final and therefore cannot be extended (without hacking the soundchannel class).
imo, tracking that in the obvious way is preferable. ie, you know when stop() is applied, do or call whatever when that occurs.
Copy link to clipboard
Copied
it's a soundcomplete event, not a soundstopped event so it makes sense to me.
and it you want to create a custom soundstopped event that dispatched when a sound stops, create it.
Copy link to clipboard
Copied
Thanks, kglad - so, there's a way in ActionScript to add custom events to custom actions in predefined components like SoundChannel?
I could surely add my own event when I call SoundChannel.stop(), but that would be without knowledge of what SoundChannel.stop() is doing internally; ideally I'd generate such an event when stop() closes an actively playing stream (one that isn't already stopped), so that would require modifying the internals of SoundChannel, wouldn't it?
- Tim
Copy link to clipboard
Copied
actually, i don't see a satisfactory way to do that because the soundchannel class is final and therefore cannot be extended (without hacking the soundchannel class).
imo, tracking that in the obvious way is preferable. ie, you know when stop() is applied, do or call whatever when that occurs.
Copy link to clipboard
Copied
Yep, that's what I ended up doing - doing whatever I'd do at a SOUND_COMPLETE after I've manually called .stop().
Thanks for your suggestion, it helped. 🙂
- Tim
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now