Page 1 of 1

[Solved] Read video from apk expansion

Posted: 15 Apr 2014 23:09
by Fradow
Hello,

I am using LibVLC in my own project. I am providing a HD tutorial video with my app, which, sadly, put me way over the 50Mb limit of the Play Store, which means I have to put the video in an apk expansion. To sum up, the apk expansion is a .obb file, which is a zip file, and can be uncompressed, so that, in theory, you can easily read what's inside without uncompressing it.

Here is how you would do with the stock MediaPlayer (ZipResourceFile and ApkExpansionSupport are in libraries provided by Google):

Code: Select all

ZipResourceFile expansionFile=null; try { expansionFile = APKExpansionSupport.getAPKExpansionZipFile(getApplicationContext(),3,0); AssetFileDescriptor fd = expansionFile.getAssetFileDescriptor("test.mp4"); MediaPlayer mPlayer = new MediaPlayer(); mPlayer.setDataSource(fd.getFileDescriptor(),fd.getStartOffset(),fd.getLength()); mPlayer.prepare(); mPlayer.start(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }
The problem is : LibVLC's Media can only be created with an URI.

I tried to look into LibVLC's code, but I have a hard time following the execution path of how the track infos are acquired, let alone how a video is played.

So here is the question: do you think there would be a somewhat easy way to add support for a method akin to setDataSource, or would that take way too much time ?

The back-up solution is to uncompress the video before reading it. Sadely, it means duplicating the content, which means lost memory for the user (Google recommend not deleting/modifying the obb file).

Thanks.

Re: Read video from apk expansion ? (uncompressed zip)

Posted: 16 Apr 2014 01:43
by Fradow
Well, after searching more and re-reading the doc carefully : "Each expansion file you upload can be any format you choose (ZIP, PDF, MP4, etc.)"

I only have one video, so I renamed it with the required file name and .obb extension. After pointing LibVLC to that file (originally a .mp4), LibVLC correctly reads it without any copy/modification.

Re: [Solved] Read video from apk expansion

Posted: 19 Apr 2014 19:15
by edwardw
Cool.