Playing a wav on ios
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Playing a wav on ios
Hi
I am trying to play a wav on an iphone when I fire a bullet in a game.
I have added the Laser2.wav to the standalone application 'copy files' area and the application compiles and deploys OK
I have the code below
command fireDart
local tSound
set the itemDelimiter to "/"
put item 1 to -2 of the filename of this stack into tSound
play tSound & "/Laser2.wav"
Put the loc of button"Malien1" into alienpos
if not exists(button "buttonShot") then
clone the button "shotTemplate"
set the name of the last button to "buttonShot"
end if
set the loc of button "buttonShot" to alienpos
put false into fireable
end fireDart
I have also tried
Play specialFolderPath("engine") & "/Laser2.wav"
In both cases the path seems correct but when I fire the bullet the sound doesn't play, the bullet fires and I am then completely thrown out of the application running on the iphone.
The exact same code works fine on the MAC.
If I take the sound playing element of the code out it works fine on the iphone but clearly no sound.
I am using the latest version of Livecode
Any suggestions please?
I am trying to play a wav on an iphone when I fire a bullet in a game.
I have added the Laser2.wav to the standalone application 'copy files' area and the application compiles and deploys OK
I have the code below
command fireDart
local tSound
set the itemDelimiter to "/"
put item 1 to -2 of the filename of this stack into tSound
play tSound & "/Laser2.wav"
Put the loc of button"Malien1" into alienpos
if not exists(button "buttonShot") then
clone the button "shotTemplate"
set the name of the last button to "buttonShot"
end if
set the loc of button "buttonShot" to alienpos
put false into fireable
end fireDart
I have also tried
Play specialFolderPath("engine") & "/Laser2.wav"
In both cases the path seems correct but when I fire the bullet the sound doesn't play, the bullet fires and I am then completely thrown out of the application running on the iphone.
The exact same code works fine on the MAC.
If I take the sound playing element of the code out it works fine on the iphone but clearly no sound.
I am using the latest version of Livecode
Any suggestions please?
Re: Playing a wav on ios
Hi neomodus,
ALWAYS use parens when concatenating path- and object names in Livecode,
EVEN if it might work without them from time to time!
Don't rely on this! EVER!
This should work:
...
play (tSound & "/Laser2.wav")
...
Hint: If you "fire" this from a SUBSTACK, use this:
...
set the itemDelimiter to "/"
put item 1 to -2 of the EFFECTIVE filename of this stack into tSound
play (tSound & "/Laser2.wav")
...
Best
Klaus
ALWAYS use parens when concatenating path- and object names in Livecode,
EVEN if it might work without them from time to time!
Don't rely on this! EVER!
This should work:
...
play (tSound & "/Laser2.wav")
...
Hint: If you "fire" this from a SUBSTACK, use this:
...
set the itemDelimiter to "/"
put item 1 to -2 of the EFFECTIVE filename of this stack into tSound
play (tSound & "/Laser2.wav")
...
Best
Klaus
Re: Playing a wav on ios
Hi Klaus
I have tried your suggestion but I am getting exactly the same issue. No sound and I get thrown out the application. Have you any other thoughts please?
I have tried your suggestion but I am getting exactly the same issue. No sound and I get thrown out the application. Have you any other thoughts please?
Re: Playing a wav on ios
Hi neomodus,
hm, maybe iOS doesn't like WAV files?
Never worked with sound on iOS, so please try an AIF or MP3 file.
Best
Klaus
hm, maybe iOS doesn't like WAV files?
Never worked with sound on iOS, so please try an AIF or MP3 file.
Best
Klaus
Re: Playing a wav on ios
Hi Klaus
I get the same problem regardless of the audio file format
I get the same problem regardless of the audio file format
Re: Playing a wav on ios
Hmmmmm?
The iOS filesystem is case-sensitive, but you surely did check for the correct filename a couple of times, right?
laser2.wav <> Laser2.wav
Sorry, out of brilliant ideas in the moment...
Oh, wait, you could check for a possible cause by adding this line:
...
play (...)
answer the result
## Should be empty on success and may give a hint if it fails!
...
The iOS filesystem is case-sensitive, but you surely did check for the correct filename a couple of times, right?
laser2.wav <> Laser2.wav
Sorry, out of brilliant ideas in the moment...
Oh, wait, you could check for a possible cause by adding this line:
...
play (...)
answer the result
## Should be empty on success and may give a hint if it fails!
...
Re: Playing a wav on ios
Hi Klaus
It returns empty then just throws me out.
It returns empty then just throws me out.
Re: Playing a wav on ios
Hmmm, sorry, out of brilliant ideas in the moment...
Oh, did you try to play the file using -> mobilePlaySoundOnChannel?
Oh, did you try to play the file using -> mobilePlaySoundOnChannel?
Re: Playing a wav on ios
Hi Klaus
The sound now works absolutely fine using mobilePlaySoundOnChannel when I test it on my old Ipad 2 using IOS 8.1.3 but I get no sound on an Iphone running IOS 6.1.6 even though the game works and it no longer throws me out of the application.
I have standalone application settings set to 6.1 or later in Livecode and am using the latest release of Livecode.
Thanks so much for your advice.
Any further suggestions please?
The sound now works absolutely fine using mobilePlaySoundOnChannel when I test it on my old Ipad 2 using IOS 8.1.3 but I get no sound on an Iphone running IOS 6.1.6 even though the game works and it no longer throws me out of the application.
I have standalone application settings set to 6.1 or later in Livecode and am using the latest release of Livecode.
Thanks so much for your advice.
Any further suggestions please?
-
- VIP Livecode Opensource Backer
- Posts: 3901
- Joined: Sat Mar 24, 2007 2:54 am
- Location: Palo Alto
Re: Playing a wav on ios
Hi neomodus,
There was someone else who had a problem here on iOS. Test using a headset.
Apparently there is some setting on the iPhone that controls this.
Or maybe there is a particular CODEC setting in the wav file (bit-rate and so on).
Simon
There was someone else who had a problem here on iOS. Test using a headset.
Apparently there is some setting on the iPhone that controls this.
Or maybe there is a particular CODEC setting in the wav file (bit-rate and so on).
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!
Re: Playing a wav on ios
Thanks so much for that. To my amazement it worked fine through earphones on the Iphone. Then my son showed me a switch that to my embarrassment solves the problem through the speakers!
-
- VIP Livecode Opensource Backer
- Posts: 3901
- Joined: Sat Mar 24, 2007 2:54 am
- Location: Palo Alto
Re: Playing a wav on ios
Hi neomodus,
Simon
Since you are at least the second person that has had problems with this, could you describe where this switch is on the iPhone? Will save others time....switch that to my embarrassment solves the problem...
Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!