Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to play .mp4 video in videoview in android?

I am working on a video player application, I want to play .mp4 video in the native video view. I am not able to play video using a URL. I am getting the error "Sorry this video cannot be played" and I am also not able to play downloaded video in the native video view either.

My code for playing video in the video view:

String mUrl = "http://www.servername.com/projects/projectname/videos/1361439400.mp4";  VideoView mVideoView  = (VideoView)findViewById(R.id.videoview) videoMediaController = new MediaController(this); mVideoView.setVideoPath(mUrl); videoMediaController.setMediaPlayer(mVideoView); mVideoView.setMediaController(videoMediaController); mVideoView.requestFocus(); mVideoView.start(); 
like image 814
Hiren Patel Avatar asked Jul 01 '13 07:07

Hiren Patel


People also ask

Can you play MP4 on PSP?

Aside from movies and music videos available commercially on UMD, the PSP can also play video files from the Memory Stick. These files must be in MP4 or AVI format. Use a free video file converter if you need to convert a video to a format playable on the PSP.

Why MP4 videos are not playing?

Reason 1: The media player you are using is not compatible with the format. Reason 2: There could be a codec issue. Reason 3: The MP4 file that you have downloaded could be broken. These are the most common reasons why you may end up looking for how to fix corrupt video files MP4 solutions.

Why won't MP4 play on my Android?

Why won't my video play? The most likely reason you see a “can't open file,” “unsupported audio codec,” or “unsupported video format" error is because your current media player doesn't support the codec of your video file. Another possible reason is that the audio codec is unsupported.


1 Answers

Finally it works for me.

private VideoView videoView;  videoView = (VideoView) findViewById(R.id.videoView);  Uri video = Uri.parse("http://www.servername.com/projects/projectname/videos/1361439400.mp4"); videoView.setVideoURI(video); videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {   @Override          public void onPrepared(MediaPlayer mp) {        mp.setLooping(true);        videoView.start();     } }); 
like image 85
Hiren Patel Avatar answered Oct 07 '22 02:10

Hiren Patel