SampleZipfileProvider 类在哪里? [英] Where is the SampleZipfileProvider class?

查看:26
本文介绍了SampleZipfileProvider 类在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Google 的扩展文件开发指南部分的底部 (http://developer.android.com/guide/market/expansion-files.html#ZipLib) 有以下文字.

At the bottom of the section in Google's dev guide on expansion files (http://developer.android.com/guide/market/expansion-files.html#ZipLib) there is the following text.

APEZProvider - 大多数应用程序不需要使用这个类.这个类定义了一个从 ZIP 编组数据的 ContentProvider通过内容提供者 Uri 提供文件以提供文件访问对于某些希望通过 Uri 访问媒体文件的 Android API.这Apk 扩展包中提供的示例应用程序演示了此类可用于指定视频的场景VideoView.setVideoURI().查看示例应用程序的类SampleZipfileProvider 有关如何将此类扩展到的示例在您的应用程序中使用.

APEZProvider - Most applications don't need to use this class. This class defines a ContentProvider that marshals the data from the ZIP files through a content provider Uri in order to provide file access for certain Android APIs that expect Uri access to media files. The sample application available in the Apk Expansion package demonstrates a scenario in which this class is useful to specify a video with VideoView.setVideoURI(). See the sample app's class SampleZipfileProvider for an example of how to extend this class to use in your application.

有问题的示例应用程序不包含此类.但它确实包含对 AndroidManifest.xml 中的 .SampleVideoPlayerActivity 文件的引用,该文件也不存在于项目中.

The sample application in question doesn't contain this class. But it does contain a reference to a .SampleVideoPlayerActivity file in the AndroidManifest.xml, which is not present in the project either.

有没有人尝试过基于 APEZProvider 实现一个具体的类并将它与 VideoView.setVideoURI() 一起使用?

Has anyone tried to implement a concrete class based on the APEZProvider and used it with VideoView.setVideoURI()?

我已经实现了这个类:

public class ZipFileContentProvider extends APEZProvider {

    @Override
    public String getAuthority() {
        return "com.myCompany.myAppName.provider.ZipFileContentProvider";
    }
}

但我不知道如何在 VideoView.setVideoURI() 调用中使用它.有人可以帮忙吗?

But I don't know how to use it with the VideoView.setVideoURI() call. Can anyone help?

推荐答案

结果证明我的 ZipFileContentProvider 已经足够了.对于那些遇到这个问题的人.这是我为 VideoView.setVideoURI() 方法使用内容提供程序所做的工作.

It turned out that my ZipFileContentProvider was sufficient. For those coming across this problem. Here is what I did to use the content provider for the VideoView.setVideoURI() method.

将提供程序添加到清单.

Add provider to Manifest.

<provider android:authorities="com.myCompany.myAppName.provider.ZipFileContentProvider" android:name=".ZipFileContentProvider"></provider>

在视频播放器类中:

final String AUTHORITY = "com.myCompany.myAppName.provider.ZipFileContentProvider";
final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY);
video = (VideoView) findViewById(R.id.video);
video.setVideoURI(Uri.parse(CONTENT_URI + "/" + videoFileName + ".mp4"));

这篇关于SampleZipfileProvider 类在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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