简体   繁体   English

如何在VideoView上播放.mp4视频

[英]How to play .mp4 video on videoview

just want to know how to play a .mp4 video on videoview. 只想知道如何在videoview上播放.mp4视频。 I got a tutorial from http://mrbool.com/how-to-play-video-formats-in-android-using-videoview/28299 and my app is not working. 我从http://mrbool.com/how-to-play-video-formats-in-android-using-videoview/28299获得了一个教程,但我的应用无法正常工作。

I followed everything. 我遵循了一切。 i named my video "video.mp4". 我将视频命名为“ video.mp4”。 I used this code to find the path of a specific video: 我使用以下代码来查找特定视频的路径:

video_player_view.setVideoPath(Environment.getDataDirectory().getAbsolutePath() + "video.mp4");

I even made a "raw" folder and placed the video there. 我什至制作了一个“原始”文件夹,并将视频放置在那里。 I used @raw/video.mp4 for it. 我用@raw/video.mp4

Can you guys help me out please. 你们能帮我吗? Thanks a lot. 非常感谢。

Try assigning the video to the videoview with setVideoURI(). 尝试使用setVideoURI()将视频分配给videoview。

vidVwYourView.setVideoURI(Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.your_video));

Just make sure 'your_video.mp4' is stored in your res/raw/ folder. 只要确保“ your_video.mp4”存储在您的res / raw /文件夹中即可。

I have the similar problem. 我有类似的问题。 In may case, I remove video file extension and it works. 在某些情况下,我会删除视频文件扩展名并且它可以工作。 So try with "video" instead of "video.mp4" 因此,请尝试使用“视频”而不是“ video.mp4”

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

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