Dual VideoView Playing 3gp Videos In Android

This example will explain how to include 2 Video View in layout to play different 3gp from at the same time.

Algorithm:

1.) Create a new project by File-> New -> Android Project name it DualVideoViewExample.

2.) Write following into main.xml:

 

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Dual VideoView" />
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="match_parent">
<VideoView
android:id="@+id/myvideoview"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<VideoView
android:id="@+id/myvideoview2"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</LinearLayout>
</LinearLayout>

 

3.) Put two 3gp video files in res/raw folder.
4.) Run for output.

Steps:

1.) Create a project named DualVideoViewExample and set the information as stated in the image.

Build Target: Android 4.4
Application Name: DualVideoViewExample
Package Name: com.example.DualVideoViewExample
Activity Name: DualVideoViewExampleActivity

dualvideoview1

2.) Open DualVideoViewExampleActivity.java file and write following code there:

 

package com.example.dualvideoviewexample;

import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;

public class DualVideoViewExampleActivity extends Activity {

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
VideoView myVideoView = (VideoView)findViewById(R.id.myvideoview);
//myVideoView.setVideoURI(Uri.parse(SrcPath));
myVideoView.setVideoURI(Uri.parse("android.resource://" + getPackageName() +"/"+R.raw.junglebook));
myVideoView.setMediaController(new MediaController(this));
myVideoView.requestFocus();
myVideoView.start();

VideoView myVideoView2 = (VideoView)findViewById(R.id.myvideoview2);
myVideoView2.setVideoURI(Uri.parse("android.resource://" + getPackageName() +"/"+R.raw.ringaroses));
myVideoView2.setMediaController(new MediaController(this));
myVideoView2.requestFocus();
myVideoView2.start();
}
}

 

 

3.) Compile and build the project.

NOTE : You can stream and play your 3gp direct from internet also instead of getting it from raw folder as shown in example.

Output

dualvideoview2