我創建開發應用程序在Android有約500 MB的視頻我用上傳apk擴展文件的方法我上傳擴展和下載,但現在我不能播放視頻從它http://blogmobile.itude.com/2012/11/22/expanding-your-horizons-using-expansion-files-for-android/我遵循這個例子播放視頻,但它不與我合作http://ktakeda47.blogspot.com/2012/04/apk-expansion-files.html我跟着這個鏈接進行擴展文件下載。現在plz幫我如何播放擴展文件中的視頻Dir =「/ sdcard/Android/obb」?如何從apk擴展文件播放視頻?
2
A
回答
1
我使用下面的代碼從OBB APKexpansion
文件中使用APKExpansionSupport
LIB播放MP4:
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());
記住 - 你得收拾OBB zip壓縮包沒有任何壓縮級別。這個非常重要。它必須是不壓縮的zip壓縮文件(級別= 0)。
However there is a URI
mentioned in APKES docs (speaking of VideoView
)但我不能得到一個膠水如何從APKES得到URI
。 Finally I found how to do it here 所以要使用URI,您必須像在他的示例中一樣擴展com.android.vending.expansion.zipfile.APEZProvider
,並對Manifest進行更改,並且它應該可以工作。