Playing a wav on ios

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
neomodus
Posts: 18
Joined: Fri Apr 13, 2012 10:27 pm

Playing a wav on ios

Post by neomodus » Fri Feb 27, 2015 3:13 pm

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?

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Playing a wav on ios

Post by Klaus » Fri Feb 27, 2015 3:26 pm

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! 8)

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

neomodus
Posts: 18
Joined: Fri Apr 13, 2012 10:27 pm

Re: Playing a wav on ios

Post by neomodus » Fri Feb 27, 2015 4:44 pm

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?

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Playing a wav on ios

Post by Klaus » Fri Feb 27, 2015 4:52 pm

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

neomodus
Posts: 18
Joined: Fri Apr 13, 2012 10:27 pm

Re: Playing a wav on ios

Post by neomodus » Fri Feb 27, 2015 7:19 pm

Hi Klaus
I get the same problem regardless of the audio file format

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Playing a wav on ios

Post by Klaus » Fri Feb 27, 2015 7:37 pm

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!
...

neomodus
Posts: 18
Joined: Fri Apr 13, 2012 10:27 pm

Re: Playing a wav on ios

Post by neomodus » Mon Mar 02, 2015 7:00 pm

Hi Klaus
It returns empty then just throws me out.

Klaus
Posts: 13829
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: Playing a wav on ios

Post by Klaus » Mon Mar 02, 2015 7:05 pm

Hmmm, sorry, out of brilliant ideas in the moment...

Oh, did you try to play the file using -> mobilePlaySoundOnChannel?

neomodus
Posts: 18
Joined: Fri Apr 13, 2012 10:27 pm

Re: Playing a wav on ios

Post by neomodus » Fri Mar 06, 2015 9:46 pm

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?

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Playing a wav on ios

Post by Simon » Fri Mar 06, 2015 11:13 pm

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

neomodus
Posts: 18
Joined: Fri Apr 13, 2012 10:27 pm

Re: Playing a wav on ios

Post by neomodus » Sat Mar 07, 2015 12:35 am

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! :D

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: Playing a wav on ios

Post by Simon » Sat Mar 07, 2015 2:57 am

Hi neomodus,
...switch that to my embarrassment solves the problem...
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.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

Post Reply

Return to “iOS Deployment”