How to use "mobilePlaySoundOnChannel"? - Solved

The place to discuss anything and everything about running your LiveCode on Android

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

How to use "mobilePlaySoundOnChannel"? - Solved

Post by DR White » Fri Sep 20, 2013 4:40 pm

Does anyone have an example of how to use "mobilePlaySoundOnChannel" with LiveCode to play an audio clip in the Android environment?

Thanks,

David
Last edited by DR White on Fri Sep 20, 2013 10:00 pm, edited 1 time in total.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: How to use "mobilePlaySoundOnChannel"?

Post by jacque » Fri Sep 20, 2013 6:19 pm

One of my Android apps does this, which works:

Code: Select all

put specialFolderPath("engine") & "/snds/" & pSndName & ".mp3" into tPath
play tPath
The sound files are in a folder named "snds" which is specified in the Copy Files pane of the standalone builder. The path that is built in the first line of this example points to that.

Sounds will only play if they are in a format the device recognizes. Not all Android devices recognize the same formats. My ancient Archos tablet understood a dozen different file types but my Samsung and Nexus do not. Virtually all devices know about mp3 though, so save your sounds that way.

Edit: Oops, I see you want a sound channel. You might not need one unless you want to play multiple sounds at the same time. But to use a sound channel, do it this way:

mobilePlaySoundOnChannel tPath, "channel1", "now"

The "channel1" parameter is any name you choose that identifies a particular channel. You name them as you go along so that if you want to play another sound on the same channel later, or queue up a couple of sounds, you have a channel name to refer to.

If you're only playing a single sound at a time, you can use my first example.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

DR White
Posts: 718
Joined: Fri Aug 23, 2013 12:29 pm

Re: How to use "mobilePlaySoundOnChannel"?

Post by DR White » Fri Sep 20, 2013 9:59 pm

Halleluiah!!!!!!!!!

Jacque YOU are AWESOME!!!!!!!!!

You have empowered my program to make beautiful sounds in an android environment!! :D :D :D

I have been trying to resolve this issue for a couple of days.

I had checked out the references that Klaus suggested, but apparently it was beyond my understanding.

I spent a couple hours reviewing other post, but I could not find any good clues.

Where did you find the information that gave you the ability to develop those couple lines of code?

I REALLY appreciate you taking extra time to give me an example code and then giving me such a great description of it

Thank YOU ever SO MUCH for your time and effort, :D :D :D

David

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7393
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: How to use "mobilePlaySoundOnChannel"?

Post by jacque » Fri Sep 20, 2013 10:21 pm

DR White wrote:Where did you find the information that gave you the ability to develop those couple lines of code?
The dictionary mostly. There's a wealth of info in there. For the sound channel entry, it says the "sound" parameter should be a file, which means I need to provide a file path. The "channel" is a name, which the comments say I should provide, which means I need to name it myself. The "type" can be any of three options, but assuming you want the sound to play immediately, I used "now".

For the plain "play" command, the dictionary entry is listed as "play file" which is a tipoff what I need to provide. The example script under that entry is the same as the one I posted here. My familiarity with the "play" command comes from years of working with the engine, so I'm not sure how other people would locate it.

We're here to help answer that sort of thing though, so don't be shy. Glad I could help.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

Post Reply