简体   繁体   中英

How to get get Uri of file in assets for argument in VideoView.setVideoURI()

I have been unsuccessful at generating a valid android.net.Uri , which references a mp4-file in my assets directory, which is required for the argument of VideoView.setVideoURI(android.net.Uri uri) .

Does anyone have a code fragment demonstrating how I can construct the Uri?

Uri.parse("file:///android_asset/path/to/your.mp4") is a Uri to a file in your assets. Whether or not you can play a video from your assets, though, I can't say, as I have never tried it.

I don't think other apps can access assets that are part of your .apk directly--you might have to copy it to the sdcard and have the PDF viewer access it from there

To copy a file from assets, you can use InputStream is = context.getAssets().open("UserGuide.pdf"); to get its content then write it into another file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM