the media player not working on android??

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

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

theshermanator
Posts: 11
Joined: Thu Apr 25, 2013 3:55 am

the media player not working on android??

Post by theshermanator » Thu Apr 25, 2013 3:59 am

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

heatherlaine
Site Admin
Site Admin
Posts: 343
Joined: Thu Feb 23, 2006 7:59 pm
Location: Wales

Re: the media player not working on android??

Post by heatherlaine » Thu Apr 25, 2013 5:31 pm

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

theshermanator
Posts: 11
Joined: Thu Apr 25, 2013 3:55 am

Re: the media player not working on android??

Post by theshermanator » Thu Apr 25, 2013 9:10 pm

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

:P :mrgreen:

rumplestiltskin
Posts: 222
Joined: Wed Jun 21, 2006 7:33 pm
Location: West of the Pecos
Contact:

Re: the media player not working on android??

Post by rumplestiltskin » Sat Oct 25, 2014 9:45 pm

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

rumplestiltskin
Posts: 222
Joined: Wed Jun 21, 2006 7:33 pm
Location: West of the Pecos
Contact:

Re: the media player not working on android??

Post by rumplestiltskin » Sat Oct 25, 2014 10:22 pm

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

rumplestiltskin
Posts: 222
Joined: Wed Jun 21, 2006 7:33 pm
Location: West of the Pecos
Contact:

Re: the media player not working on android??

Post by rumplestiltskin » Sat Oct 25, 2014 10:49 pm

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
path to audio file.png (23.42 KiB) Viewed 9571 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,

Code: Select all

mobileControlDo "play" , PATHNAME
...would play. (Am I correct there?)

Thanks,
Barry

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: the media player not working on android??

Post by Simon » Sat Oct 25, 2014 11:32 pm

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
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

rumplestiltskin
Posts: 222
Joined: Wed Jun 21, 2006 7:33 pm
Location: West of the Pecos
Contact:

Re: the media player not working on android??

Post by rumplestiltskin » Sun Oct 26, 2014 12:36 am

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

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: the media player not working on android??

Post by Simon » Sun Oct 26, 2014 12:48 am

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"
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

rumplestiltskin
Posts: 222
Joined: Wed Jun 21, 2006 7:33 pm
Location: West of the Pecos
Contact:

Re: the media player not working on android??

Post by rumplestiltskin » Sun Oct 26, 2014 1:14 am

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. :D

Barry

PS - Yes, the filename I show is correct with the (96kb) included in the name.

rumplestiltskin
Posts: 222
Joined: Wed Jun 21, 2006 7:33 pm
Location: West of the Pecos
Contact:

Re: the media player not working on android??

Post by rumplestiltskin » Sun Oct 26, 2014 1:23 am

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

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: the media player not working on android??

Post by Simon » Sun Oct 26, 2014 1:58 am

Hi Barry,
Try this
Play.zip
(99.2 KiB) Downloaded 260 times
it's running here on Android.

Extract the whole folder so that the sound file can be attached.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

rumplestiltskin
Posts: 222
Joined: Wed Jun 21, 2006 7:33 pm
Location: West of the Pecos
Contact:

Re: the media player not working on android??

Post by rumplestiltskin » Sun Oct 26, 2014 2:18 am

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? :shock:

Simon
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3901
Joined: Sat Mar 24, 2007 2:54 am
Location: Palo Alto

Re: the media player not working on android??

Post by Simon » Sun Oct 26, 2014 2:21 am

Yeppers! :D

Now note that the voice.mp3 was not in a subfolder... that is your next test.

Simon
I used to be a newbie but then I learned how to spell teh correctly and now I'm a noob!

rumplestiltskin
Posts: 222
Joined: Wed Jun 21, 2006 7:33 pm
Location: West of the Pecos
Contact:

Re: the media player not working on android??

Post by rumplestiltskin » Sun Oct 26, 2014 2:23 am

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

Post Reply

Return to “Android Deployment”