Exporting a LiveCode App with Audio

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Steve Whyte
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 4
Joined: Wed Nov 02, 2011 11:01 am

Exporting a LiveCode App with Audio

Post by Steve Whyte » Wed Nov 02, 2011 11:16 am

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

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Exporting a LiveCode App with Audio

Post by Klaus » Wed Nov 02, 2011 11:47 am

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

1152601
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1
Joined: Sat Jun 18, 2011 8:10 pm

Re: Exporting a LiveCode App with Audio

Post by 1152601 » Wed Nov 02, 2011 12:56 pm

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

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Exporting a LiveCode App with Audio

Post by Klaus » Wed Nov 02, 2011 1:24 pm

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

Steve Whyte
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 4
Joined: Wed Nov 02, 2011 11:01 am

Re: Exporting a LiveCode App with Audio

Post by Steve Whyte » Wed Nov 02, 2011 7:16 pm

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!

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Exporting a LiveCode App with Audio

Post by Klaus » Wed Nov 02, 2011 7:39 pm

Glad I could help!


Best

Klaus

sjennings
Posts: 7
Joined: Sat Nov 05, 2011 8:35 pm

Re: Exporting a LiveCode App with Audio

Post by sjennings » Sun Nov 06, 2011 6:32 pm

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?

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Exporting a LiveCode App with Audio

Post by Mark » Mon Nov 07, 2011 3:12 am

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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

sjennings
Posts: 7
Joined: Sat Nov 05, 2011 8:35 pm

Re: Exporting a LiveCode App with Audio

Post by sjennings » Mon Nov 07, 2011 4:55 am

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?

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Exporting a LiveCode App with Audio

Post by Mark » Mon Nov 07, 2011 5:08 am

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
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

sjennings
Posts: 7
Joined: Sat Nov 05, 2011 8:35 pm

Re: Exporting a LiveCode App with Audio

Post by sjennings » Tue Nov 08, 2011 4:59 am

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?

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Re: Exporting a LiveCode App with Audio

Post by Mark » Fri Nov 11, 2011 1:09 pm

Hi ...,

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

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

Post Reply