How to play mp3 sounds in android with Livecode?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Fasasoftware
Posts: 203
Joined: Mon Oct 31, 2011 9:36 pm
Location: Italy
Contact:

How to play mp3 sounds in android with Livecode?

Post by Fasasoftware » Tue Oct 22, 2019 10:15 pm

How to play mp3 sounds in android with Livecode?

If i put this code....i hear sound in my android phone....

Code: Select all

global gPath

on mouseUp
   put specialFolderPath("engine") into gPath
   play audioClip (gPath &"/Cow.wav")
end mouseUp

buti if i put this....this code don't work....I need my sounds played in MP3... the sounds don't work..

Code: Select all

global gPath

on mouseUp
   put specialFolderPath("engine") into gPath
   play audioClip (gPath &"/Cow.mp3")
end mouseUp

Can somebody help me please???? best regards, Lestroso :oops: :oops: :oops:

bogs
Posts: 5435
Joined: Sat Feb 25, 2017 10:45 pm

Re: How to play mp3 sounds in android with Livecode?

Post by bogs » Tue Oct 22, 2019 10:24 pm

http://lessons.livecode.com/m/4071/l/25230-play-sounds wrote: It is important to note at this point that audioclips in Livecode can be in either .WAV, .AIFF, or .AU format.
Sorry Lestroso, I don't think you can play mp3's in Lc :(

Cyril's page seems to say different, though.
https://sites.google.com/a/pgcps.org/livecode/programming-tasks/playing-music wrote: Add a sound effect
find and import a sound effect ("File", "Import as Control", "Audio File") - It has to be a "wav" or "mp3" file
add a button and put the following code in it"

Code: Select all

                on mouseUp
                        play "firecracker.wav"
                end mouseUp
So maybe it is as simple as removing 'audioclip' from your line? The BYU also suggests that to play an mp3, you'd use the player object, give it a shot :D
Image

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

Re: How to play mp3 sounds in android with Livecode?

Post by Klaus » Wed Oct 23, 2019 9:21 am

Hi Lestroso,

MP3 files should also play on Android, however you should try the official syntax for MOBILE,
which is different from the syntax for desktop, please always check the dictionary when in doubt!

Code: Select all

global gPath

on mouseUp
   put specialFolderPath("resources") into gPath
   play soundfile (gPath &"/Cow.mp3")
end mouseUp
Hint:
Get used to use -> specialfolderpath("resources") instead of specialfolderpath("engine")
This happens to be the same folder on the mobile platform, but "resources" does also work on the desktop and in the IDE!
In the IDE it points to the folder where the current stack is in.


Best

Klaus

P.S.
Imported sounds are NOT supported on the mobile platform!

Fasasoftware
Posts: 203
Joined: Mon Oct 31, 2011 9:36 pm
Location: Italy
Contact:

Re: How to play mp3 sounds in android with Livecode?

Post by Fasasoftware » Wed Oct 23, 2019 6:31 pm

Dear friends, bogs and klaus.....

Thanks you for your answer.... i have tested this problem....with success....
I'm be able to play sounds MP3 files in my android app and works fine!!

ok the code working is this...:

Code: Select all

global gPath

on mouseUp
   put specialFolderPath("resources") into gPath
   play audioClip (gPath &"/Cow.mp3")
end mouseUp
You must use specialfolderpath("resources") , here the example here up on the top... instead of specialfolderpath("engine") that you must setup when you enclose your sounds in the panel "STANDALONE APPLICATION SETTINGS in the "Copyfiles" section!!!!
In my case ... i have had include my sound file as a direct path...for example..so: /Users/lestroso/Desktop/toesounds/Cat.mp3
Works Fine!!!!
I hope this help you...best regards, Lestroso :D :D :D

Post Reply

Return to “Getting Started with LiveCode - Experienced Developers”