Page 1 of 2
the media player not working on android??
Posted: Thu Apr 25, 2013 3:59 am
by theshermanator
Does the media player not work with android devices?
I successfully added a streaming audio .PLS url to the media device which works find when I create a mac osx standalone or when I test in the livecode stack.
But when I save as an android app the media object shows up as a blue ugly bar and sits there and does nothing. It won't play.
Is there a special setting for this on android?
I am trying to play an MP3 URL or a PLS url
Re: the media player not working on android??
Posted: Thu Apr 25, 2013 5:31 pm
by heatherlaine
You need to create a native Android player using the mobileControlCreate command. The player object in the IDE is for desktop only.
I hope this helps,
Regards,
Heather
Customer Services Manager
RunRev Ltd
Re: the media player not working on android??
Posted: Thu Apr 25, 2013 9:10 pm
by theshermanator
I've fixed the issue with both local and MP3 urls and streaming audio from internet radio stations. All now successfully play on an android device.
Please see,
http://forums.runrev.com/viewtopic.php?f=7&t=14911

Re: the media player not working on android??
Posted: Sat Oct 25, 2014 9:45 pm
by rumplestiltskin
heatherlaine wrote:You need to create a native Android player using the mobileControlCreate command. The player object in the IDE is for desktop only.
I hope this helps,
Regards,
Heather
Customer Services Manager
RunRev Ltd
Heather,
So the command must be called while the app is running in the Android environment? I suppose the preOpenStack handler would be the place to create all the necessary controls if I have a one card app. I'll give an example of a stack I developed for OSX and Windows in which I imported audio (AIF) clips and played them using the "play" command. In Android, however, I'd need to use:
Code: Select all
mobileControlCreate "player" , "myPlayer1"
I'm assuming "myPlayer1" is simply the name of the player which I may use thusly:
Code: Select all
mobileControlDo "myPlayer1", "play"
...but how do I actually assign the audio clip to that player?
Thanks,
Barry
Re: the media player not working on android??
Posted: Sat Oct 25, 2014 10:22 pm
by rumplestiltskin
Okay; I think I'm getting a bit closer.
Code: Select all
mobileControlCreate "player" , "myPlayer1"
...creates the player.
Code: Select all
mobileControlSet "myPlayer1" , "visible" , false
...sets the player invisible.
Code: Select all
mobileControlSet "myPlayer1" , "filename" , PATHNAME-TO-AUDIO
...sets the path to the clip???
...so to play the clip I would then use
Code: Select all
mobileControDo "myPlayer1" , "play"
Am I correct? If so, how do I determine what the pathname is of my audio clip assuming I've imported it into the stack in the IDE on OSX?
Thanks,
Barry
Re: the media player not working on android??
Posted: Sat Oct 25, 2014 10:49 pm
by rumplestiltskin
I'm still groping around in the dark. I've attached inline a screenshot showing an audio file I've added using the "Copy Folder" facility in the Standalone Application Settings dialog. Apparently it used the containing folder ("LivecodeAndroidTest") as well as the folder I created called "Audio".
(By the way, I was able to examine this by duplicating the .apk file, changing its extension to .zip and then unzipping the file to reveal the contents.)

- path to audio file.png (23.42 KiB) Viewed 11464 times
So some questions come to mind:
1. May I move the Audio folder up a level (into "assets") and then delete the "LivecodeAndroidtest" folder? I'd then re-zip the folder and rename it with the proper .apk extension.
2. What would be the pathname of my audio clip which, presumably,
...would play. (Am I correct there?)
Thanks,
Barry
Re: the media player not working on android??
Posted: Sat Oct 25, 2014 11:32 pm
by Simon
Hi Barry,
On mobile content copied using the Copy Files in standalone settings end up in
specialFolderPath ("engine")
So if you copied a folder named Assets that contained myBest.mp3 then the path is
specialFolderPath ("engine") & "/Assets/myBest.mp3"
There was recently a lot of trouble with copying a folder (6.5 may have it fixed but I haven't tested it yet) so you should start with just copying the file itself (e.g. myBest.mp3) and not the whole folder.
Simon
Re: the media player not working on android??
Posted: Sun Oct 26, 2014 12:36 am
by rumplestiltskin
Simon,
Thanks for your reply. I think I'm not quite understanding things (or there's a bug). I'm using Community Edition 7.0 (stable). I have a button on the stack with this code in it:
Code: Select all
on mouseUp
mobileControlCreate "player" , "player1"
mobileControlSet "player1" , "visible" , false
mobileControlSet "player1" , "rect" , "0,0,0,0"
mobileControlSet "player1" , "filename" , specialFolderPath(engine) & "assets/LivecodeAndroidtest/Audio/Click(96kb).mp3"
mobilControlDo "player1" , "play"
end mouseUp
I examined the .apk file by duplicating it in the Finder, changing it's extension to .zip, and then unzipping it where I could see the exact path to the audio file (which I've used for my script).
When I install the .apk in my Nexus 5 and launch the app, I tap on the button and see the screen flash black momentarily. (I think this is a bug someone else reported and maybe if I alter my script I can prevent that flash. However, no audio file plays. I'm at a loss to understand what I'm doing wrong here.
Thanks,
Barry
Re: the media player not working on android??
Posted: Sun Oct 26, 2014 12:48 am
by Simon
Hi Barry,
You don't show the quotes around the engine ("engine") and missing the slash before assets ("/assets...").
And does your filename actually contain (96kb)??
Forget looking at the package.
And as I said, for starters just use the single file and not a folder.
Simon
Edit; If you are doing nothing more then playing a sound then this is easier
play specialFolderPath("engine") & "/myBest.mp3"
Re: the media player not working on android??
Posted: Sun Oct 26, 2014 1:14 am
by rumplestiltskin
Simon,
I added the quotes and the slash. No sound.
I then changed that line of code as (I think) you were suggesting:
Code: Select all
mobileControlSet "player1" , "filename" , specialFolderPath("engine") & "/Click(96kb).mp3"
Again, no sound (but I still get that black flash regardless).
Any other suggestions? I'll keep coding.
Barry
PS - Yes, the filename I show is correct with the (96kb) included in the name.
Re: the media player not working on android??
Posted: Sun Oct 26, 2014 1:23 am
by rumplestiltskin
On a hunch, I tried a longer sound as the "click" sound was only .13 sec long. I replaced it with another sound that was about 4 seconds long (and modified the filename in the script accordingly. No luck. Still no sound.
Barry
Re: the media player not working on android??
Posted: Sun Oct 26, 2014 1:58 am
by Simon
Hi Barry,
Try this
- Play.zip
- (99.2 KiB) Downloaded 329 times
it's running here on Android.
Extract the whole folder so that the sound file can be attached.
Simon
Re: the media player not working on android??
Posted: Sun Oct 26, 2014 2:18 am
by rumplestiltskin
It worked. Now I'm really confused.
Nowhere in your stack do I see anything like the "mobileControlSet" or "mobileControlDo" commands that I used in my stack (and that I thought were mandatory in Android). All I see is the play command. Is that it?

Re: the media player not working on android??
Posted: Sun Oct 26, 2014 2:21 am
by Simon
Yeppers!
Now note that the voice.mp3 was not in a subfolder... that is your next test.
Simon
Re: the media player not working on android??
Posted: Sun Oct 26, 2014 2:23 am
by rumplestiltskin
Yes; my audio file wasn't in the same folder as my stack so that's undoubtedly why there was a more complicated path. I'll report back when I try this on my stack. Thanks very much for your time and effort on my behalf.
Barry