将视频文件放在android项目中的位置 [英] Where to put the Video file in android Project
问题描述
我有一个视频,我需要知道该视频的放置位置和获取路径.
I have a video, I need to know where to place and how to get the path of that video.
我知道如何添加视频表单网址
I know how to add the video form URL,
Uri uri=Uri.parse("www.abc.com/myVid.mp4");
videoView = (VideoView) findViewById(R.id.videoView);
videoView.setVideoURI(uri);
这很好,但是现在视频文件在我的项目中,我需要知道如何从文件夹结构中获取路径
This works fine, but now the video file is in my project, I need to know how to get the path from the folder structure
请引导我.
谢谢
推荐答案
您可以在项目内创建资产文件夹,并将视频存储在该文件夹中.
You can create asset folder inside your project and store your video in that folder.
然后,您可以使用Android
提供的getAssets()
函数获得该功能.
Then you can get that using getAssets()
function which is provided by Android
.
您可以单击项目"窗口,按Alt-Insert,然后选择文件夹"->资产"文件夹. Android Studio会将其自动添加到正确的位置.
You can click on the Project window, press Alt-Insert, and select Folder -> Assets Folder. Android Studio will add it automatically to the correct location.
此外,您可以执行此操作.
Also, you can do this.
VideoView view = (VideoView)findViewById(R.id.videoView);
String path = "android.resource://" + getPackageName() + "/" + R.raw.video_file;
view.setVideoURI(Uri.parse(path));
view.start();
其中video_file
是您的文件名.
这篇关于将视频文件放在android项目中的位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!