Can I access/play user's music on iOS/Android (music *NOT* in my sandbox)?

Hi,

I want to write a jukebox / music player … and have access to the music already on the iOS or Android device.

I know this is possible with native development (Objective C/Swift on iOS, C on Android), because I’ve got apps like that (that I don’t like :slight_smile: on both iOS and Android.

So … Corona seems to be unable to play a sound file that isn’t in my sandbox.

Perhaps I’m overlooking something?

(I’ve tried the “…/…/” approach, but it doesn’t seem to let me climb out of the sandbox.)

thanks,

Stan

I don’t think this can be done with standard Corona.  You’ll probably need a plugin for this.

There is an iTunes plugin for iOS based apps that should be able to access the device’s music library. There is a community plugin that can get you to an Android’s external storage.  This isn’t a very “cross-platform” thing to do, but the systems handle music drastically different.

Rob

Rob, I’ve now purchased Scott’s external storage plugin.  For the benefit of future readers, it’s at:

   https://marketplace.coronalabs.com/plugin/external-storage

The inability of Corona to access accessible native media files (i.e., files whose permission lets me read them)

is mind boggling.  I *CAN* read such files (e.g., io.open() and <filehandle>:read), so we know that they’re accessible.

The drawback to the plugin approach is that I have to copy .mp3 files to my Corona sandbox in order to play them.

I shouldn’t have to copy them!  That introduces a potentially significant time-lag, and introduces the spectre of file-storage leakage.

The Corona SDK entire approach to files / directories is somewhat wonky, but even in the current system,

there should be a trivially easy way to signal to a function like audio.loadSound that the path is relative to the system root ("/"),

not the sandbox root.  (E.g., system.realRootDirectory returning a constant directory handle, or some such.)

Yeah, there’s a chance that fix … ok, sigh, enhancement … might not be applicable to iOS, but it would be meaningful/useful

on Android, Mac, and Windows.

Guess I should start a list of things to change when I become CTO? :slight_smile:

@Rob … even with the help of my friend, Google, I can’t find a plugin for iOS that accesses media files.

Can you provide a name or a link, please?

This brings up something: the marketplace needs a better search mechanism.

For example, ability to require (or exclude) iOS or Android.

One way to easily implement this (without changing the user interface, which can take longer to implement, and can

raise thorny questions) is to allow extra keywords in the search field:

   +ios     — require the keyword iOS in the app description

   -android    – don’t return any hits that have the word android in the description

that would let me search for:    media -ios

Speaking of which, the search is broken anyway.  Try:

    external storage android             … 0 hits

   external storage                         … 1 hit, and it has Android in the first sentence!

thanks,

Stan

https://marketplace.coronalabs.com/plugin/itunes

sieler2, don’t waste your time trying to build a music player with Corona. you can’t even play music with your app minimized or closed. who listen music with app always on top of the screen?

Thanks, @carloscosta … I hadn’t tested that area yet.

Wait… ok …

I haven’t tried on iOS yet, but on Android, the song will continue playing until the end, and then … 

any event generated (e.g. “finished playing”) is left pending until I bring the app back to “focus”, sigh.

I don’t think this can be done with standard Corona.  You’ll probably need a plugin for this.

There is an iTunes plugin for iOS based apps that should be able to access the device’s music library. There is a community plugin that can get you to an Android’s external storage.  This isn’t a very “cross-platform” thing to do, but the systems handle music drastically different.

Rob

Rob, I’ve now purchased Scott’s external storage plugin.  For the benefit of future readers, it’s at:

   https://marketplace.coronalabs.com/plugin/external-storage

The inability of Corona to access accessible native media files (i.e., files whose permission lets me read them)

is mind boggling.  I *CAN* read such files (e.g., io.open() and <filehandle>:read), so we know that they’re accessible.

The drawback to the plugin approach is that I have to copy .mp3 files to my Corona sandbox in order to play them.

I shouldn’t have to copy them!  That introduces a potentially significant time-lag, and introduces the spectre of file-storage leakage.

The Corona SDK entire approach to files / directories is somewhat wonky, but even in the current system,

there should be a trivially easy way to signal to a function like audio.loadSound that the path is relative to the system root ("/"),

not the sandbox root.  (E.g., system.realRootDirectory returning a constant directory handle, or some such.)

Yeah, there’s a chance that fix … ok, sigh, enhancement … might not be applicable to iOS, but it would be meaningful/useful

on Android, Mac, and Windows.

Guess I should start a list of things to change when I become CTO? :slight_smile:

@Rob … even with the help of my friend, Google, I can’t find a plugin for iOS that accesses media files.

Can you provide a name or a link, please?

This brings up something: the marketplace needs a better search mechanism.

For example, ability to require (or exclude) iOS or Android.

One way to easily implement this (without changing the user interface, which can take longer to implement, and can

raise thorny questions) is to allow extra keywords in the search field:

   +ios     — require the keyword iOS in the app description

   -android    – don’t return any hits that have the word android in the description

that would let me search for:    media -ios

Speaking of which, the search is broken anyway.  Try:

    external storage android             … 0 hits

   external storage                         … 1 hit, and it has Android in the first sentence!

thanks,

Stan

https://marketplace.coronalabs.com/plugin/itunes

sieler2, don’t waste your time trying to build a music player with Corona. you can’t even play music with your app minimized or closed. who listen music with app always on top of the screen?

Thanks, @carloscosta … I hadn’t tested that area yet.

Wait… ok …

I haven’t tried on iOS yet, but on Android, the song will continue playing until the end, and then … 

any event generated (e.g. “finished playing”) is left pending until I bring the app back to “focus”, sigh.