[Audio] How to play a sound n times in A5?
How to play a sample and/or an audio stream n times in A5?
I mean play it eg. 5 times then stop.
possible solution are:
1. listen the play complete event
2. get audio length and use a timer
the 1 solution seems not supported in A5 now.
the 2 solution works in A5.
My question is:
1. is there any better solution?
2. how can i listen the play complete event? (I need this not only for repeating but also for user callback)
Create sample instances and use the functions associated with sample instances to play it. You can then use al_get_sample_instance_playing(...) to check if it's still playing.
Manual page for your convenience: Audio Routines (Scroll down a bit for sample instance functions)
Thanks for replying.
And I think the al_get_sample_instance_playing() is a polling manner,
that is i have keeps check it.
I'd prefer the event notify manner if possible.
I haven't seen anything that outputs an event when a sample stops, but I haven't really been playing sounds so I can't be sure. If you really want an event you could create a user event and send that, but you would still need to poll the sample.
Thread #607720. Printed from Allegro.cc
For streams I know there is:
If the stream is created by al_load_audio_stream then it can also generate an ALLEGRO_EVENT_AUDIO_STREAM_FINISHED event if it reaches the end of the file and is not set to loop.