Put the video inside the res/raw
Layout - vidconsult.xml
<?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" >
<VideoView android:id="@+id/vidview"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
</VideoView>
</LinearLayout>
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.Toast;
import android.widget.VideoView;
public class playvid extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.vidconsult);
VideoView myVideoView = (VideoView) findViewById(R.id.vidview);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(myVideoView);
try{//try to fetch vid from sdcard
//String SrcPath = "/sdcard/week17boy.avi";//put your video in sdcard
String vidpath = "android.resource://" + getPackageName() + "/" + R.raw.rsr;
myVideoView.setVideoURI(Uri.parse(vidpath));
//myVideoView.setVideoPath(SrcPath);
myVideoView.setMediaController(new MediaController(this));
myVideoView.requestFocus();
myVideoView.start();
}
catch (Exception e){
Toast.makeText(getApplicationContext(), e.toString(), Toast.LENGTH_SHORT);
}
}
}
I had copy all ur code an run it... but it show cnt play video...
ReplyDeleteThe fact that the emulator could not play the video really well. You need to test the video playback using actual device...
DeleteThanks a lot :D
ReplyDeleteit worked but i cannot see the video .. just the music
ReplyDeletei cannot see the video in emulator .. just the music
ReplyDeleteThe fact that the emulator could not play the video really well. You need to test the video playback using actual device...
Delete