I'm currently working on a music game for which I am using large sound files featuring many 2 seconds audio cues that I've put one after another.
So to be clear the audio file is something like:
0-2 sec : sound / 2-3 sec : silence / 3-5 sec : another sound / 5-6 sec : silence ... etc ...
This is necessary to reduce the number of assets so that my server could play the game correctly.
Now I need to create a function which :
1) Plays the sound at time (param 0) with tag (Param 1)
(no problem for this part)
2) After 2.5 seconds, stops the sound playing at tag (param 1) (or else the large sound file continues playing other sounds).
Here it becomes more problematic. I can do it as long as there is only one sound playing at a time. The problem is that I need up to 4 sounds to be played at the same time with this function from the same file, and as soon as a second sound is playing, the first sound played won't stop. Of course I'm giving different tags here, I even tried to add a random value in the tag I'm giving.
I tried many things, such as using a return value with the tag of the audio to stop, and then stopping the audio in the event which called the function instead of in the function itself. I also created a stop function called inside the play function, but in both cases the result is not better.
Is there any way to achieve this?
Thanks for any help!