在Android项目中放置视频文件的位置(Where to put the Video file in android Project)

[db:摘要]

在Android项目中放置视频文件的位置(Where to put the Video file in android Project)

我有一个视频,我需要知道在哪里放置以及如何获得该视频的路径。

我知道如何添加视频表单网址,

Uri uri=Uri.parse("www.abc.com/myVid.mp4"); videoView = (VideoView) findViewById(R.id.videoView); videoView.setVideoURI(uri);

这工作正常,但现在视频文件在我的项目中,我需要知道如何从文件夹结构中获取路径

请引导我。

谢谢

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

Kindly guide me.

Thanks

最满意答案

您可以在项目中创建资产文件夹,并将视频存储在该文件夹中。

然后你可以使用Android提供的getAssets()函数来获取它。

编辑1:

您可以单击项目窗口,按Alt-Insert,然后选择Folder - > Assets Folder。 Android Studio会自动将其添加到正确的位置。

另外,你可以做到这一点。

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是您的文件名。

You can create asset folder inside your project and store your video in that folder.

Then you can get that using getAssets() function which is provided by Android.

EDIT 1:

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();

Where video_file is your file name.

发布者:admin,转转请注明出处:http://www.yc00.com/web/1692089384a568028.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信