Android VideoView Example

In android we can play the video using videoview. Here is a simple and easy way to play the video.
Android VideoView Example :
video.xml
[sourcecode language="xml"]
<?xml version="1.0" encoding="utf-8"?>

<LinearLayout android:id="@+id/LinearLayout01"
android:layout_height="fill_parent" xmlns:android="http://schemas.android.com/apk/res/android"
android:paddingLeft="2px" android:paddingRight="2px"
android:paddingTop="2px" android:paddingBottom="2px"
android:layout_width="fill_parent" android:orientation="vertical">

<VideoView android:layout_height="fill_parent"
android:layout_width="fill_parent" android:id="@+id/VideoView"></VideoView>

</LinearLayout>

[/sourcecode]
Java File
[sourcecode language="java"]
public class VideoPlayerController extends Activity {

@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

setContentView(R.layout.video);

VideoView videoView = (VideoView) findViewById(R.id.VideoView);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);
// Set video link (mp4 format )
Uri video = Uri.parse("mp4 video link");
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.start();

}
}
[/sourcecode]
Try this!..

Comments

hi Hwa, i think

hi Hwa,
i think we can use RSTP links from youtube. Try to get those links and stream it.

i am not sure. Android

i am not sure. Android supports only 3gp and mp4.

Try running it in device

Try running it in device rather than emulator. Emulator does not plays video in most occasions .

Hey asma, Have you tried

Hey asma,

Have you tried with mp4 link ?..

Hey asma, Instead of giving

Hey asma,

Instead of giving http://www.streetfire.net/video/lagrange-dragstri... like this.. use direct URL and check it.

http://www.streetfire.net/video/songname.mp4 like this

walwoul, try it on device.

walwoul,

try it on device.

walwoul, you can't run video

walwoul,
you can't run video in emulator. The video will surely play in device.