playing audio on Android

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

playing audio on Android

Post by keram » Tue Apr 22, 2014 12:08 pm

Hi,

After reading few posts about problems with playing audio files on Android devices I'm still not sure what should be done.
My tablet is supporting audio formats: AAC, AAC+, AMR-NB, AMR-WB, eAAC+, MP3, OGG, WAV, WMA, AC-3, FLAC. I used a wav file that plays OK in IDE but not in the android standalone.

So I'd like to confirm:

1. If I import the audio file as Control, do I have to Copy Files in the Standalone Application Settings as well?
if yes,

2. Do I have to specify the path for it?
if yes,

3. is the path below correct?
put specialFolderPath("engine") into gPath
and
put this in the handler:
play audioClip file (gPath &"/audio.wav")

keram
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

LCNeil
Livecode Staff Member
Livecode Staff Member
Posts: 1223
Joined: Wed Oct 03, 2012 4:07 pm

Re: playing audio on Android

Post by LCNeil » Tue Apr 22, 2014 12:23 pm

Hi Keram,

The imported audio controls will not playback when deployed to either iOS and Android. As you have mentioned, you will need to use the "Copy Files" section of your standalone application settings if you wish to include any audio/video within your mobile apps.

Your script is almost correct but you do not need "file" after your play command. Remember to declare your global variable as well.

I have tested the following and the sound plays as expected-

Code: Select all

global gPath

on mouseUp
   put specialFolderPath("engine") into gPath
   play audioClip (gPath &"/audio.wav")
end mouseUp
Kind Regards,


Neil Roger
--
RunRev Support Team ~ http://www.runrev.com
——

keram
Posts: 340
Joined: Fri Nov 08, 2013 4:22 am

Re: playing audio on Android

Post by keram » Tue Apr 22, 2014 1:29 pm

Thanks Neil,
runrevneil wrote:you will need to use the "Copy Files" section of your standalone application settings if you wish to include any audio/video within your mobile apps.
Does it meant that in this case I'm not limited to the use of only audio wav files that LC can play but can use mp3 files that most of the mobiles can play?
Or is the ability to play particular formats in standalones dependent on LC engine as well?

keram
Using the latest stable version of LC Community 6.7.x on Win 7 Home Premium, 64bit

LCNeil
Livecode Staff Member
Livecode Staff Member
Posts: 1223
Joined: Wed Oct 03, 2012 4:07 pm

Re: playing audio on Android

Post by LCNeil » Tue Apr 22, 2014 1:36 pm

Hi Keram,

With this method you are not limited to WAVS as MP3's will work fine. A list of the media formats that are supported by default on Android can be viewed at the following link-

http://developer.android.com/guide/appe ... rmats.html

Kind Regards,


Neil Roger
--
RunRev Support Team ~ http://www.runrev.com
——

newtronsols
Posts: 192
Joined: Tue Mar 11, 2014 12:57 pm

Re: playing audio on Android

Post by newtronsols » Thu Apr 24, 2014 3:22 pm

I got this to work on Android:
by ticking Copy Referenced Files, and the destination folder became _ReferencedFiles

adamkatz2003
Posts: 3
Joined: Mon Nov 09, 2020 7:22 pm

Re: playing audio on Android

Post by adamkatz2003 » Mon Nov 09, 2020 7:25 pm

HI i know that i replay couple of years later but can i get a test project to learn from? i can't get the audio to work on my device

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

Re: playing audio on Android

Post by Klaus » Mon Nov 09, 2020 8:04 pm

Hi Adam,

welcome to the forum!
Add your sound(s) via the "Copy files" tab in the "Standalone Application Settings".
You will find them in your standalone in -> specialfolderpath("resources")

Code: Select all

...
play audioClip (specialfolderpath("resources") &"/your_audio.wav")
...
Best

Klaus

Post Reply

Return to “Getting Started with LiveCode - Complete Beginners”