问题
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";
}
}
回答1:
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.
来源:https://stackoverflow.com/questions/13813185/android-play-movie-inside-expansion-file