Page 1 of 1

Exporting a LiveCode App with Audio

Posted: Wed Nov 02, 2011 11:16 am
by Steve Whyte
Hi,

I've developed a very simple animation which includes audio in LiveCode 5.0.

I've deployed the app to an iPad and despite the audio playing OK on my desktop, it will not work on the iPad. It could be with the type of sound file I'm using. The file was embedded into the stack as a .wav.

I've tried to convert it to an aiff file format and will test to see if that works.

Has anyone had any similar issues or does anyone know how to sort this? I see that LiveCode doesn't support mp3.

Regards,

Steven

Re: Exporting a LiveCode App with Audio

Posted: Wed Nov 02, 2011 11:47 am
by Klaus
Hi Steven,

the trick is to keep ALL of your sounds as SEPARATE files, since iOS does not support "play ac XYZ" with internal/imported sounds!
If you keep them inside of your application package you can access then via:
specialfolderpath("engine")


WAV should also work on iOS, but AIFF, MP4 or MP3 might be better.
Yes, on iOS MP3 is supported with PLAY...!


Best

Klaus

Re: Exporting a LiveCode App with Audio

Posted: Wed Nov 02, 2011 12:56 pm
by 1152601
Hi Klaus, I am working with Steven on the animations.

I have Imported as control the file sound.mp3 and then tried to get it to work with the line

play audioclip specialfolderpath ("engine")&"/sound.mp3"

I can hear a click but no other sound is played. Again if I just change the line to play audioclip "sound.mp3" I just hear the click and no sound. Aiff and wav files play ok using the play audioclip command but not mp3's.

We are using OSX.

I import all sounds individually using the Import as Control command. Should I be importing them in some other manner?
Also, is there a way of deleting audio files that are embedded within a livecode program?

Many thanks
Allan

Re: Exporting a LiveCode App with Audio

Posted: Wed Nov 02, 2011 1:24 pm
by Klaus
Hi Allan,

big misunderstanding 8)

You can NOT play imported (as control) sounds on iOS, you need to use and play EXTERNAL files!

So add your sounds via the "Copy files" Tab in the standalone builder and then you can access them via:
play (specialfolderpath("engine") & "/sound.mp3")
## No keyword "audioclip" on iOS!

Problem is that iOS CAN play MP3 but the IDE on the desktop does NOT!

Deleting sounds:
Go to the LiveCode preferences -> Application Browser and check "show audio clips"
They will then appear in the AB you can delete them via right-click there.


Best

Klaus

Re: Exporting a LiveCode App with Audio

Posted: Wed Nov 02, 2011 7:16 pm
by Steve Whyte
Thanks for your great help. All is working fine now after doing what you said.

It is a pity that LiveCode doesn't support mp3's but hey, it's working! :D

Thanks again!

Re: Exporting a LiveCode App with Audio

Posted: Wed Nov 02, 2011 7:39 pm
by Klaus
Glad I could help!


Best

Klaus

Re: Exporting a LiveCode App with Audio

Posted: Sun Nov 06, 2011 6:32 pm
by sjennings
Hi, I know this post was a while back but I have the same problem with Android. I tried the same solution, but it did not work. How do I import audio to play on Android?

Re: Exporting a LiveCode App with Audio

Posted: Mon Nov 07, 2011 3:12 am
by Mark
Hi,

You DON'T IMPORT SOUND FILES into a mobile app. Instead, you save the files together with your standalone, i.e. next to your standalone, as separate files, and you use the play command with a path to the sound file. The path to the sound file should be

Code: Select all

set the itemDel to slash
put (item 1 to -2 of the effective filename of this stack) & "/filename.mp3" into myPath
but the path may be different, depending on where you store the files exactly.

Kind regards,

Mark

Re: Exporting a LiveCode App with Audio

Posted: Mon Nov 07, 2011 4:55 am
by sjennings
I tried it but it didn't work. After "put (item 1 to -2 of the effective filename of this stack) & "/filename.mp3" into myPath" do I just "play audioClip "filename.mp3" ". Also what is myPath exactly?

Re: Exporting a LiveCode App with Audio

Posted: Mon Nov 07, 2011 5:08 am
by Mark
Hi,

You path is:

Code: Select all

(item 1 to -2 of the effective filename of this stack) & "/filename.mp3"
where you have to replace filename.mp3 with the actual name of your file (obviously).

As I wrote, you use the play command with the path, not just the filename. Which means that

Code: Select all

play audioClip "filename.mp3"
is just plain wrong but

Code: Select all

play audioClip (item 1 to -2 of the effective filename of this stack) & "/filename.mp3"
would be correct.

Kind regards,

Mark

Re: Exporting a LiveCode App with Audio

Posted: Tue Nov 08, 2011 4:59 am
by sjennings
Thanks for the response, but this also did not work on the Android phone. Is the path the path of the audio on the computer or on the phone? If its on the phone how would I find that path?

Re: Exporting a LiveCode App with Audio

Posted: Fri Nov 11, 2011 1:09 pm
by Mark
Hi ...,

(item 1 to -2 of the effective filename of this stack) & "/filename.mp3"
or
specialfolderpath("engine") & "/filename.mp3"

Mark