I create developing app in android which have about 500 mb video i use for uploading apk expansion files method i upload expansion and download it but now i cant play videos from it http://blogmobile.itude.com/2012/11/22/expanding-your-horizons-using-expansion-files-for-android/ i follow this example for playing video but it's not working with me http://ktakeda47.blogspot.com/2012/04/apk-expansion-files.html i followed this link for expansion file downloading .Now plz help me how to play videos from expansion file Dir="/sdcard/Android/obb" ?
Asked
Active
Viewed 2,652 times
1 Answers
2
I'm using the following code to play mp4 from obb APKexpansion
file using APKExpansionSupport
lib:
ZipResourceFile expansionFile = null;
AssetFileDescriptor mAFD= null;
try {
expansionFile = APKExpansionSupport.getAPKExpansionZipFile(this, 1, 0);
mAFD = expansionFile.getAssetFileDescriptor(strVideoFile);
} catch (IOException e) {
e.printStackTrace();
} catch (NullPointerException e) {
e.printStackTrace();
}
if (expansionFile==null || mAFD == null){
Toast.makeText(this, "obb is not here or doesn't contain file: "+strVideoFile, Toast.LENGTH_LONG).show();
return false;
}
mMediaPlayer.setDataSource(mAFD.getFileDescriptor(), mAFD.getStartOffset(), mAFD.getLength());
Remember - you have to pack obb zip archive without any compression level. This is very important. It must be a zip archive with no compression (level=0).
However there is a URI
mentioned in APKES docs (speaking of VideoView
) but I cant get a glue how to get the URI
from APKES. Finally I found how to do it here
So to use URI you has to extend com.android.vending.expansion.zipfile.APEZProvider
like in his example and make changes to Manifest and it should work.