Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!
I would want to know how to play a lot of audio file simultaneously ? i have a background music and when i press a button a sound is playing but i when i press a button the background music stopped.
on preOpenCard
play audioClip "backgroundmusic" looping
en preOpenCard
command WhenIClickOnAButton
play audioClip "pressButton"
end WhenIClickOnAButton
on CloseCard
play stop # stop the background music
end CloseCard
have you tried to use player objects for your sounds instead of the play audioClip command.
from the dictionary for the play command
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.
see dictionary for "player", 2 player objects can play at the same time.
on preOpenCard
player1
player2
StartPlayer1
end preOpenCard
command player2
create player "lecteur2"
put specialFolderPath("ressources") & "/musique/pressButton.wav" into Mentrer
set the filename of player "lecteur2" to Mentrer
end player2
command player1
create player "lecteur1"
put specialFolderPath("ressources") & "/musique/backgroundmusic.wav" into Mmenu
set the filename of player "lecteur1" to Mmenu
end player1
command StartPlayer1
start player "lecteur1"
loop
end StartPlayer1
command loop
if (the duration of player "lecteur1" = the currentTime of player "lecteur1") then
loopPlayer1
end if
send "loopPlayer1" to me in 100 milliseconds
end loop
Last edited by problème on Sat Nov 28, 2015 2:56 pm, edited 1 time in total.
command player1
create player "lecteur1"
set the LOOPING of player "lecteur1" to TRUE
put specialFolderPath("ressources") & "/musique/backgroundmusic.wav" into Mmenu
set the filename of player "lecteur1" to Mmenu
end player1
First entry for "loop" in the dictionary!
Any special reason why you always create new objects via script instead of creating them ONCE (manually),
like the player objects here, and just re-use them?
it was for the tests.
i will create my player in the mainstrack script, when i open my application i go to card "home screen" the backgroundmusic start, when i go to card 2 the backgroundmusic continue. But i don't want my players appear
I can't use object player in different card through different card like audioClip.
Last edited by problème on Sat Nov 28, 2015 3:28 pm, edited 1 time in total.
To have a player on several cards as you noted, you need to GROUP that player and PLACE that group on all cards where the sound should play.
Then you can hide the player/group!
Of course you can do everything by script, but that's a lot of scripting!
So why not prepare your players (create and set all neccessary properties manually) and use them further on?