开发者

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

开发者 https://www.devze.com 2023-02-25 07:35 出处:网络
I have been unsuccess开发者_高级运维ful 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.n

I have been unsuccess开发者_高级运维ful 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消