[Solved] Read video from apk expansion

VLC for Android and Chrome OS specific usage questions
Fradow
Blank Cone
Blank Cone
Posts: 22
Joined: 10 Jan 2014 17:44

[Solved] Read video from apk expansion

Postby Fradow » 15 Apr 2014 23:09

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.
Last edited by Fradow on 16 Apr 2014 01:44, edited 1 time in total.

Fradow
Blank Cone
Blank Cone
Posts: 22
Joined: 10 Jan 2014 17:44

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

Postby Fradow » 16 Apr 2014 01:43

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.

edwardw
Big Cone-huna
Big Cone-huna
Posts: 2346
Joined: 24 Jun 2012 23:36
VLC version: 3.0.0-git

Re: [Solved] Read video from apk expansion

Postby edwardw » 19 Apr 2014 19:15

Cool.


Return to “VLC for Android and Chrome OS”

Who is online

Users browsing this forum: No registered users and 10 guests