如何从APK扩展文件播放视频? [英] How to play video from apk expansion files?

查看:411
本文介绍了如何从APK扩展文件播放视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

创建开发的应用程序在Android中其中有大约500 MB的视频我使用上传APK扩展文件的方法我上传的扩展和下载,但现在我不能从它播放视频<一href="http://blogmobile.itude.com/2012/11/22/expanding-your-horizons-using-expansion-files-for-android/" rel="nofollow">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帮助我如何从扩展文件目录播放视频=/ SD卡/安卓/ OBB ?

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" ?

推荐答案

我用下面的code。使用播放从OBB APKexpansion 文件MP4 APKExpansionSupport lib目录下:

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());

请记住 - 你得收拾OBB ZIP压缩包没有任何COM pression水平。这是非常重要的。它必须是一个zip压缩包,没有COM pression(级别= 0)。
但是有​​一个 URI 提在APKES文档(讲的 VideoView ,但我不能让胶水如何获得 URI 从APKES。 最后,我发现怎么这里做 因此,要使用URI你有延长 com.android.vending.expansion.zipfile.APEZProvider 像他为榜样,更改的体现,它应该工作。

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.

这篇关于如何从APK扩展文件播放视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆