Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Tier1: Queuing Sound Playback (with code?)

Author
Message
anwserman
13
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 24th Dec 2013 01:32 Edited at: 24th Dec 2013 01:34
So using Tier1, I'm wanting to queue the playback of sound files; they get thrown into a queue, and one finishes playing, the next one in the queue starts to play. Once all of the sounds are done playing, the queue gets purged and then starts over once new sounds are added.

This would be really easy to do if I kept it in a private for/each loop, but I also need to perform other tasks, like increasing a background timer. So there goes loops.

I have some code jotted down below as pseudo-code. Anyone have any suggestions or might know how to tackle this?



Hi there. My name is Dug. I have just met you, and I love you.
easter bunny
12
Years of Service
User Offline
Joined: 20th Nov 2012
Playing: Dota 2
Posted: 24th Dec 2013 01:40 Edited at: 24th Dec 2013 01:58
The sound commands have auto looping built in.

Do it like this:

id1=LoadMusic("foobar1.mp3")
id2=LoadMusic("foobar2.mp3")
id3=LoadMusic("foobar3.mp3")
id4=LoadMusic("foobar4.mp3")

`PlayMusic( iID, bLoop, iStartID, iEndID )
PlayMusic( id1, 1, id1, id4)

anwserman
13
Years of Service
User Offline
Joined: 20th May 2011
Location: Wisconsin
Posted: 24th Dec 2013 02:08
Quote: "
Do it like this:
id1=LoadMusic("foobar1.mp3")
id2=LoadMusic("foobar2.mp3")
id3=LoadMusic("foobar3.mp3")
id4=LoadMusic("foobar4.mp3")

`PlayMusic( iID, bLoop, iStartID, iEndID )
PlayMusic( id1, 1, id1, id4)"


That's exactly *not* what I want. I want sounds to be played, not music. By queuing sounds up, I could build sentences to be played once in a while like:

The big, fat / (cow, dog, cat, lemur, iguana) / jumped over the moon.

What you suggest removes the possibility of having background music being played, it also puts all of the sound files on an endless loop, and also doesn't address whether or not my background timer should get paused during playback.

Hi there. My name is Dug. I have just met you, and I love you.
easter bunny
12
Years of Service
User Offline
Joined: 20th Nov 2012
Playing: Dota 2
Posted: 24th Dec 2013 04:27
Ok, well that complicated things

I'm sure you'll figure something out

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 24th Dec 2013 14:36
with GetSoundsPlaying you are on the right way.
but you should reset the finish var before you set the next
active index.
also soundStarted =0 if a sound finished.

AGK 108 B19 : Windows 8.1 Pro 64 Bit : AMD Radeon HD 6670
xGEKKOx
AGK Master
15
Years of Service
User Offline
Joined: 7th Dec 2008
Location: Italy
Posted: 24th Dec 2013 18:42
Well is simple.
Just do an array, and count it.
Take in memory which number of array is playing, and when the sound is over (getSoundPlaying) go to next.
When you reach the size of array start again.

As Markus suggested you need only to take care to remember some switch vars.


Long life to Steve!
Naphier
14
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 24th Dec 2013 22:45
Untested code:



Again this is untested, but it should give you an idea of how to loop through sounds. Keeping tally of what sound to play next is key. Note that in this code you could alter the sequence whenever you want to play sounds in a different order.
Hope this helps.

Login to post a reply

Server time is: 2024-11-24 23:29:03
Your offset time is: 2024-11-24 23:29:03