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

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

问题描述

我在Android中创建开发应用程序,它有大约500 mb的视频,我用于上传apk扩展文件方法我上传扩展和下载,但现在我无法播放视频 http://blogmobile.itude.com/2012/11/22/expanding-你的-horizo​​ns-using-expansion-files-for-android / 我按照这个例子播放视频,但它不能与我一起工作 http://ktakeda47.blogspot.com/2012/04/apk-expansion-files.html 我遵循此链接进行扩展文件下载。现在帮助我如何从扩展文件播放视频Dir =/ sdcard / Android / 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" ?

推荐答案

我正在使用以下使用 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存档没有任何压缩级别。这个非常重要。它必须是没有压缩的zip压缩(级别= 0)。

URI (谈到 VideoView ,但是不能得到一个胶水如何从APKES获取 URI 最后我找到了如何在这里
所以要使用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天全站免登陆