Apply two Sounds at the same time LiveCode 8 (RC1)
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Apply two Sounds at the same time LiveCode 8 (RC1)
Hello,
In my project I have a background music implemented on preOpenCard which continues over 1-2 cards.
While the music is playing, i wanted to add another sound, for example if I click on a button that it makes a "click" sound effect or an animal sound effect but while the background music is still running.
I tried to implement both the same way with ' play "mySound.wav" ' which i "imported as Control" first of all, but when I click for example on the button the click sounds plays but the background music stops.
Is there a way without extension or anything like that only with raw liveCode to make 2 sounds playing at the same time possible?
(I am currently using LiveCode Community 8 (RC1) on a macbook air.
I Hope you can help me.
Kind Regards
Mark
In my project I have a background music implemented on preOpenCard which continues over 1-2 cards.
While the music is playing, i wanted to add another sound, for example if I click on a button that it makes a "click" sound effect or an animal sound effect but while the background music is still running.
I tried to implement both the same way with ' play "mySound.wav" ' which i "imported as Control" first of all, but when I click for example on the button the click sounds plays but the background music stops.
Is there a way without extension or anything like that only with raw liveCode to make 2 sounds playing at the same time possible?
(I am currently using LiveCode Community 8 (RC1) on a macbook air.
I Hope you can help me.
Kind Regards
Mark
Re: Apply two Sounds at the same time LiveCode 8 (RC1)
Hi Mark,
if in doubt, always take a look at the dictionary!
From the docs about "play..."
....
If you start playing an audio clip when another one is playing, the first audio clip is stopped,
and a playStopped message is sent to the current card. You cannot play two sounds at the same time,
nor can you queue a sound while another sound is playing.
...
So you need to set up two player objects (or maybe only one for your bg music/sound), but these only work
with external files and you need to set their filename property.
This way you can have as many sounds as you like playing at the same time.
Best
Klaus
if in doubt, always take a look at the dictionary!
From the docs about "play..."
....
If you start playing an audio clip when another one is playing, the first audio clip is stopped,
and a playStopped message is sent to the current card. You cannot play two sounds at the same time,
nor can you queue a sound while another sound is playing.
...
So you need to set up two player objects (or maybe only one for your bg music/sound), but these only work
with external files and you need to set their filename property.
This way you can have as many sounds as you like playing at the same time.
Best
Klaus
Re: Apply two Sounds at the same time LiveCode 8 (RC1)
Hello,
Oh Ok sorry my bad i am still a newbie.
Hmm that's unfortunate because I am not allowed to use extensions in my project.
Well, can't do anything about it. Thank you anyways.
Best Regards
Mark
Oh Ok sorry my bad i am still a newbie.
Hmm that's unfortunate because I am not allowed to use extensions in my project.
Well, can't do anything about it. Thank you anyways.

Best Regards
Mark
Re: Apply two Sounds at the same time LiveCode 8 (RC1)
Hi Mark,
sorry compeltely forgot this one: Welcome to the forum!
What you you mean "no externsions allowed"?
QuickTime (and nowadays AVFoundation) is the underlying multimedia engine of
operation system (!) and LC is only using it, as all other audio/video apps on the Mac do!
Best
Klaus
sorry compeltely forgot this one: Welcome to the forum!

What you you mean "no externsions allowed"?
QuickTime (and nowadays AVFoundation) is the underlying multimedia engine of
operation system (!) and LC is only using it, as all other audio/video apps on the Mac do!
Best
Klaus
Re: Apply two Sounds at the same time LiveCode 8 (RC1)
Hey Klaus,
I am a student at university and I have to make a project with LiveCode.
In the script the prof wrote that" we are not allowed to use external links or datas, no substacks and no externals etc".
So because of this I don't want to risk my project to be not evaluated.
(And I also don't know how to use externals etc.
)
Best
Mark
I am a student at university and I have to make a project with LiveCode.
In the script the prof wrote that" we are not allowed to use external links or datas, no substacks and no externals etc".
So because of this I don't want to risk my project to be not evaluated.
(And I also don't know how to use externals etc.

Best
Mark
Re: Apply two Sounds at the same time LiveCode 8 (RC1)
Ah, "...no external datas...", I see.
OK, bad luck (and a silly restriction in my opinion, internal or external sounds, what's the difference?)
OK, bad luck (and a silly restriction in my opinion, internal or external sounds, what's the difference?)

Re: Apply two Sounds at the same time LiveCode 8 (RC1)
You could ask whether including an audio file on disk is considered an external resource. Or you can just work around the problem with a little trick.
Store the raw audio file in a custom property of the stack. When you need to play the audio, write the file to disk in the user's temporary folder. Assign the temp path to the player control and start playback. When the app quits, or whenever you're done with the audio, delete the temporary file.
I've done this in more than one app and it works fine. Ask if you need help with any of the steps. You'll probably need to look at the tempName entry in the dictionary.
Store the raw audio file in a custom property of the stack. When you need to play the audio, write the file to disk in the user's temporary folder. Assign the temp path to the player control and start playback. When the app quits, or whenever you're done with the audio, delete the temporary file.
I've done this in more than one app and it works fine. Ask if you need help with any of the steps. You'll probably need to look at the tempName entry in the dictionary.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
-
- Posts: 115
- Joined: Thu Mar 06, 2014 9:29 am
Re: Apply two Sounds at the same time LiveCode 8 (RC1)
And if after pulling your audio from a custom prop you still don't want to use QuickTime, you can always play multiple sounds simultaneously via html and JavaScript in a browser instance.
Re: Apply two Sounds at the same time LiveCode 8 (RC1)
OK, thank you very much for the help.
I am going to see my prof next week so I will ask him there if I could do it like you suggested.
Best
Mark
I am going to see my prof next week so I will ask him there if I could do it like you suggested.
Best
Mark