Pierre Gallaz
Posts: 0
Joined: Wed May 20, 2015 11:52 am

How can I play mp3 sounds stored in a zipped Android APK expansion file using the audio control ? ("src=?")

Hi,

I am creating an app, at first only for Android, that plays various guided meditation and yoga exercises in mp3 format using the "audio" control.

Part of the mp3 files are stored locally in the source, added to a subfolder inside WEB_RESSOURCES, and it works great. However, because of the APK 50mb size limitation, some other mp3 files have to be accessed via streaming, using external links pointing to my own web site.

I would like to avoid having to use streaming altogether.

I looked at this thread:

https://c.getsatisfaction.com/apperyi...

...which is what allowed me to find out about using the WEB_RESSOURCES folder, but I am not skilled enough to be able to use the phonegap tools mentioned by Kateryna at the bottom of the thread to download the extra audio after installation of the app, and I was looking for a simpler fix.

Then I read the documentation here about the APK expansion files, and it looks promising:

http://developer.android.com/google/p...

It seems that the best option, since there are several mp3 files, would be to zip them all together without compression, and it should then be possible to play each invidual file inside the zipped archive, as they write in the android.com link:

"Tip: If you're packaging media files into a ZIP, you can use media playback calls on the files with offset and length controls (such as MediaPlayer.setDataSource() and SoundPool.load()) without the need to unpack your ZIP. In order for this to work, you must not perform additional compression on the media files when creating the ZIP packages. For example, when using the zip tool, you should use the -n option to specify the file suffixes that should not be compressed:
zip -n .mp4;.ogg main_expansion media_files."

My question is: if I manage to create such an APK expansion file, how do I access the mp3 inside? What do I write under "src:" in the audio control properties?

Or do you have any other, simpler option, that would maybe also work for IOS and Windows Phone, that would allow to download the audio files separately?

Thanks a lot.

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

How can I play mp3 sounds stored in a zipped Android APK expansion file using the audio control ? ("src=?")

Hello Pierre,

The best way is to use exernal mp3 files. If you want to use local files - you can get access to them via src=my.mp3 if my.mp3 located in WEB_RESOURCES directory

Pierre Gallaz
Posts: 0
Joined: Wed May 20, 2015 11:52 am

How can I play mp3 sounds stored in a zipped Android APK expansion file using the audio control ? ("src=?")

Hello Sergiy,

Thanks for your anwer.

As I said, That's exactly what I did. I used WEB_RESOURCES. But Google play only allows 50mb size max for an APK, and my mp3s use more space than that, so I can not store them all in WEB_RESOURCES. I have to find a different way.

What do you call "external mp3 files"? How would they download after the user installed the app from Google Play? Can you provide me with a script?

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

How can I play mp3 sounds stored in a zipped Android APK expansion file using the audio control ? ("src=?")

Hi Pierre,

There are only two ways to access files:

1 Store them into app binary and then use them locally(without network).

2 Store them into network cloud service and access them from network.

Regards.

Pierre Gallaz
Posts: 0
Joined: Wed May 20, 2015 11:52 am

How can I play mp3 sounds stored in a zipped Android APK expansion file using the audio control ? ("src=?")

Thanks, Yuri. That's what I thought. 2 last questions:

1) Could the offline mode that Appery just released help in any way in this situation?

http://www.prweb.com/releases/2015/05...

2) Someone mentioned using a phonegap script to download the audio files on the app's first launch here, with your approval in this thread:

https://getsatisfaction.com/apperyio/...

Is that solution still a good one?

Kind regards,

Pierre

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

How can I play mp3 sounds stored in a zipped Android APK expansion file using the audio control ? ("src=?")

Hello Pierre,

Sorry for late reply here.

  1. Please read more about API Express offline mode here https://devcenter.appery.io/documenta...
    But this is something different, you need to use post download.
    That's why try this http://docs.phonegap.com/en/edge/cord... to download file on device.
  2. Please look at this thread https://getsatisfaction.com/apperyio/...
Pierre Gallaz
Posts: 0
Joined: Wed May 20, 2015 11:52 am

How can I play mp3 sounds stored in a zipped Android APK expansion file using the audio control ? ("src=?")

Thanks Alena, very helpful. I will look into it and let you know the results.

Return to “Issues”