Does anyone have an example of how to use "mobilePlaySoundOnChannel" with LiveCode to play an audio clip in the Android environment?
Thanks,
David
How to use "mobilePlaySoundOnChannel"? - Solved
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
How to use "mobilePlaySoundOnChannel"? - Solved
Last edited by DR White on Fri Sep 20, 2013 10:00 pm, edited 1 time in total.
Re: How to use "mobilePlaySoundOnChannel"?
One of my Android apps does this, which works:
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.
Code: Select all
put specialFolderPath("engine") & "/snds/" & pSndName & ".mp3" into tPath
play tPath
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
HyperActive Software | http://www.hyperactivesw.com
Re: How to use "mobilePlaySoundOnChannel"?
Halleluiah!!!!!!!!!
Jacque YOU are AWESOME!!!!!!!!!
You have empowered my program to make beautiful sounds in an android environment!!
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,
David
Jacque YOU are AWESOME!!!!!!!!!
You have empowered my program to make beautiful sounds in an android environment!!



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,



David
Re: How to use "mobilePlaySoundOnChannel"?
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".DR White wrote:Where did you find the information that gave you the ability to develop those couple lines of code?
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
HyperActive Software | http://www.hyperactivesw.com