简体   繁体   English

如何在VideoView.setVideoURI()中获取参数资产的Uri文件

[英]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) . 我没有成功生成有效的android.net.Uri ,它引用了我的资产目录中的mp4文件,这是VideoView.setVideoURI(android.net.Uri uri)的参数所必需的。

Does anyone have a code fragment demonstrating how I can construct the Uri? 有没有人有一个代码片段来演示我如何构建Uri?

Uri.parse("file:///android_asset/path/to/your.mp4") is a Uri to a file in your assets. Uri.parse("file:///android_asset/path/to/your.mp4")是资产中文件的Uri 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 我不认为其他应用程序可以直接访问属于.apk的资产 - 您可能需要将其复制到SD卡并让PDF查看器从那里访问它

To copy a file from assets, you can use InputStream is = context.getAssets().open("UserGuide.pdf"); 要从资产中复制文件,可以使用InputStream is = context.getAssets()。open(“UserGuide.pdf”); to get its content then write it into another file. 获取其内容然后将其写入另一个文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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