9

My app is trying to deliver lots of contents to users, so the app's size is much greater than 50mb. There is no way we could reduce or remove some of the content, so we decided to go with the expansion approach.

I am trying to follow this tutorial: Android APK Expansion Files, and have been successful up to putting the expansion file into my device for testing. I could get the input stream of any video file inside the expansion. But when I try to setVideoUri for the videoView, it starts crashing. Here are some code:

ZipFileContentProvider contentProvider = new ZipFileContentProvider();
String contentPath = "content://";
File root = Environment.getExternalStorageDirectory();
String EXP_PATH = File.separator + "Android" + File.separator + "obb" + File.separator;
String path = root.toString() + EXP_PATH + context.getPackageName() + File.separator + "main.1.com.c4e1.in2cricket.obb";
String zipFileName =  contentPath + path + "/" + fileName;
Uri uri = Uri.parse(zipFileName);
videoView.setVideoUri(uri);


public class ZipFileContentProvider extends APEZProvider {

    @Override
    public String getAuthority() {
        return "com.c4e1.in2cricket.provider.ZipFileContentProvider";
    }
}
vodkhang
  • 18,639
  • 11
  • 76
  • 110
  • Have you seen this question (regarding crashes of expansion files): http://stackoverflow.com/questions/10051213/accessing-apk-expansion-file-with-uri-with-google-zip-expansion-library-causes – Victor Ronin Dec 16 '12 at 23:14
  • It is not the same problem as mine – vodkhang Dec 17 '12 at 02:38

1 Answers1

2

While working with zip and obb files it's always a good practice to log the zipEntries you are dealing with.

Check this log to ensure your assumptions are correct.

Use APEZProvider for mediaplayer to provide uri.

Check this in standard android document.

Hope this will help you.

Ajay Kumar Meher
  • 1,932
  • 16
  • 24
  • http://stackoverflow.com/questions/12635069/accessing-to-files-inside-obb-expansion-file this might help you to work with. – Ajay Kumar Meher Dec 20 '12 at 12:43
  • Doesn't seem to help, I could get the input stream for my videos – vodkhang Dec 20 '12 at 13:11
  • Please verify using is.available() to see the size of your stream. If size is as per your expectation use it as dataSource() and prepare your mediaplayer with prepareAsync(). – Ajay Kumar Meher Dec 20 '12 at 13:31
  • http://stackoverflow.com/questions/10051213/accessing-apk-expansion-file-with-uri-with-google-zip-expansion-library-causes?lq=1 Check this for how to use APEZProvider. – Ajay Kumar Meher Dec 21 '12 at 04:45