Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
156 views
in Technique[技术] by (71.8m points)

android - Where is the SampleZipfileProvider class?

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 - 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.

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.

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

I have implemented the class:

public class ZipFileContentProvider extends APEZProvider {

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

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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>

In video player class:

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

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...