内部扩展文件的Andr​​oid播放电影文件、电影、Andr、oid

2023-09-06 01:52:31 作者:爱睡觉の大懒虫

我的应用程序正试图以提供大量的内容给用户,使应用程序的大小超过50MB大得多。有没有办法,我们可以减少或去除一些内容,所以我们决定去与扩张的方式。

我想按照这个教程:的Andr​​oid APK扩展文件,并获得了成功最多把扩展文件到我的设备进行测试。我能得到扩大内的任何视频文件的输入流。但是,当我尝试setVideoUri为videoView,它开始崩溃。下面是一些code:

  ZipFileContentProvider的ContentProvider =新ZipFileContentProvider();
字符串的contentPath =内容://;
文件根= Environment.getExternalStorageDirectory();
字符串EXP_PATH =文件分割符+Android的+文件分割符+楼宇更新大行动+文件分割符;
字符串路径= root.toString()+ EXP_PATH + context.getPackageName()+文件分割符+main.1.com.c4e1.in2cricket.obb;
字符串zipFileName =的contentPath +路径+/+文件名;
开放的我们的uri = Uri.parse(zipFileName);
videoView.setVideoUri(URI);


公共类ZipFileContentProvider扩展APEZProvider {

    @覆盖
    公共字符串getAuthority(){
        返回com.c4e1.in2cricket.provider.ZipFileContentProvider;
    }
}
 

解决方案

虽然有拉链和OBB文件的工作,它总是一个很好的做法,记录你正在处理的。

的zipEntries

检查此日志,以确保你的假设是正确的。

使用APEZProvider为媒体播放器提供URI。

为此,检查标准Android文档。

希望这会帮助你。

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";
    }
}

解决方案

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.