简体   繁体   中英

How to play .mp4 video on videoview

just want to know how to play a .mp4 video on videoview. I got a tutorial from http://mrbool.com/how-to-play-video-formats-in-android-using-videoview/28299 and my app is not working.

I followed everything. i named my video "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.

Can you guys help me out please. Thanks a lot.

Try assigning the video to the videoview with setVideoURI().

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

Just make sure 'your_video.mp4' is stored in your res/raw/ folder.

I have the similar problem. In may case, I remove video file extension and it works. So try with "video" instead of "video.mp4"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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