Play a user MP3

Hi Corona users,

I would like to allow a user to add (manually) mp3 files to the document directory, and to play them with Corona.

My need is to allow an Android user to play an mp3 of his choice (not pre-installed with the app). On iOS I can use the iTunes plugin to play external mp3, but it’s not available on Android. So I’m looking for another way.

My plan B was to ask the Android users to copy their mp3 in the document directory of the app. But I cannot see where the document directory of my Corona app is…

Any idea?

Look for system.documentsDirectory in the docs

Thanks rmbsoft for your reply.

I did of course, but it not mentions how a user can add a file in this directory. Is this directory exists on the Android device when the app is installed, and where it is. I tried to find it with a file browser on several devices with no success.

On iOS it’s easy, the feature is included in iTunes.

Hi @dmekersa,

Did you read through the guide on reading and writing files?

http://docs.coronalabs.com/guide/data/readWriteFiles/index.html

Also, if you’re curious how to see the “Documents directory” from the Corona Simulator (as it would exist), go to:

File > Show Project Sandbox > [Project Folder] > Documents

Hope this helps,

Brent

Thanks Brent, I saw this guide. It not explains how a user can add some files in this directory. By “add” I mean, connect an Android device to a computer, and copy an MP3 in the directory. I don’t mean by code.

With iOS, it’s easy: connect the device, go in iTunes / Phone / Apps -> Click on the app -> the document directory is displayed and the user can add/remove files in it.

But how with Android?

You can use network.download() to download files from a server, but there are no built in API calls to connect to another computer that doesn’t support HTTP or FTP or similar transfer protocols.

With Android, you can’t tether your device to your computer and access the apps sandbox.  This is how Google secures the system.  Now if you’re device is rooted you can get to it.  Now in theory, you could put files in the device’s download directory and then use LFS to get access to them, but I don’t know if the Corona API calls can access the folders.  There is likely some Java/Native processes that can be accessed via Enterprise to copy them as well.

Rob

Thanks Rob, I’ll follow the “download” track…

Look for system.documentsDirectory in the docs

Thanks rmbsoft for your reply.

I did of course, but it not mentions how a user can add a file in this directory. Is this directory exists on the Android device when the app is installed, and where it is. I tried to find it with a file browser on several devices with no success.

On iOS it’s easy, the feature is included in iTunes.

Hi @dmekersa,

Did you read through the guide on reading and writing files?

http://docs.coronalabs.com/guide/data/readWriteFiles/index.html

Also, if you’re curious how to see the “Documents directory” from the Corona Simulator (as it would exist), go to:

File > Show Project Sandbox > [Project Folder] > Documents

Hope this helps,

Brent

Thanks Brent, I saw this guide. It not explains how a user can add some files in this directory. By “add” I mean, connect an Android device to a computer, and copy an MP3 in the directory. I don’t mean by code.

With iOS, it’s easy: connect the device, go in iTunes / Phone / Apps -> Click on the app -> the document directory is displayed and the user can add/remove files in it.

But how with Android?

You can use network.download() to download files from a server, but there are no built in API calls to connect to another computer that doesn’t support HTTP or FTP or similar transfer protocols.

With Android, you can’t tether your device to your computer and access the apps sandbox.  This is how Google secures the system.  Now if you’re device is rooted you can get to it.  Now in theory, you could put files in the device’s download directory and then use LFS to get access to them, but I don’t know if the Corona API calls can access the folders.  There is likely some Java/Native processes that can be accessed via Enterprise to copy them as well.

Rob

Thanks Rob, I’ll follow the “download” track…