How to play videos in VideoView?

I want to play a video in a VideoView . When I try to do this, I got the following error:

Here is my source code:

 package com.video.listitem; import android.app.Activity; import android.content.pm.ActivityInfo; import android.media.MediaPlayer; import android.net.Uri; import android.os.Bundle; import android.view.Window; import android.view.WindowManager; import android.widget.MediaController; import android.widget.VideoView; public class PlayVideo extends Activity { VideoView mVideoView; MediaController mc; String videourl; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.requestWindowFeature(Window.FEATURE_NO_TITLE); this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); setContentView(R.layout.videoplay); try { mVideoView = (VideoView) findViewById(R.id.videoview); String videourl = "rtsp://v7.cache4.c.youtube.com/CiILENy73wIaGQl25yDUbxNXTRMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp"; mc = new MediaController(this); mVideoView.setMediaController(mc); mVideoView.requestFocus(); mVideoView.setVideoURI(Uri.parse(videourl)); mc.show(); mVideoView.start(); } catch (Exception e) { //TODO: handle exception } } } 

Here is my xml file:

 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:scrollbars="none" android:gravity="center"> <VideoView android:layout_width="fill_parent" android:layout_height="fill_parent" android:id="@+id/videoview" /> </LinearLayout> 
+4
source share
5 answers

Try to run the application on the device, the video may not work in the emulator ...

+3
source

Try adding permission to connect to the Internet!

 uses-permission android:name="android.permission.INTERNET" 
+1
source

see my answere here in the given code example. If the video does not play, try recoding it using a program such as Handbrake and try again. Supported Video Formats Information: Supported Android Media Formats

+1
source

The URL may be incorrect. Try playing this stream using a vlc player. If it is reproducing, we can consider another possible reason.

-3
source

Ok, the first thing you want to do is clear your layout, this is your first problem:

release it first and make the problem visible:

You should have caught the error that your cover lid is missing after the center, "just add a"> "... and that. Clear the project and you will see the rtsp video. And your internet resolution, as stated earlier.

-3
source

All Articles