如何从资产文件夹加载视频?(用 VideoView 播放它们) [英] How to load videos from assets folder? (to play them with VideoView)

查看:34
本文介绍了如何从资产文件夹加载视频?(用 VideoView 播放它们)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从资产文件夹中打开一个 mp4 视频并使用 VideoView 播放.

I need to open a mp4 video from the assets folder and play it with VideoView.

我尝试了这两个选项,但它们都不起作用......

I tryed with these two options, but none of them works....

mVideoView.setVideoPath("file:///android_asset/videos.mp4");
mVideoView.requestFocus();
mVideoView.start();

还有……

String uriPath = "file:///android_asset/videos.mp4";
Uri uri = Uri.parse(uriPath);
mVideoView.setVideoURI(uri);
mVideoView.requestFocus();
mVideoView.start();

这些选项不起作用,但如果我尝试从 SDCARD 打开视频,它可以完美运行,那么,问题是当我尝试从资产文件夹加载视频时.

These options didn't works, but if I try to open the video from the SDCARD it works perfectly, then, the problem is when I'm trying to load the video from the assets folder.

我做错了什么?

谢谢

推荐答案

我不知道如何从资产文件夹加载视频.但我知道如何从/res/raw/文件夹加载它们:

I don't know how to load videos from the assets folder. But I know how to load them from the /res/raw/ folder:

String uriPath = "android.resource://yourapplicationpackage/raw/videofilenamewithoutextension";
Uri uri = Uri.parse(uriPath);
video.setVideoURI(uri);

这篇关于如何从资产文件夹加载视频?(用 VideoView 播放它们)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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