Play video in android, play video from sdcard
In this example,i'll show you to play video from sdcard
Create object of videoView in your activity
VideoView obj=(VideoView)findViewId(R.id.videoView1);
Set path of file
Obj.setVideoPath(“sdcard/path of file.3gp”);
Now call
Obj.setMediaController(new MediaController);
main.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" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <VideoView android:layout_height="wrap_content" android:id="@+id/videoView1" android:layout_width="match_parent"> </VideoView> </LinearLayout> |
VideoPlayerActivity.java
package com.example; import android.app.Activity; import android.os.Bundle; import android.widget.MediaController; import android.widget.VideoView; public class VidePlayerActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); VideoView videoView=(VideoView)findViewById(R.id.videoView1); videoView.setVideoPath("sdcard/Padaiyappa - minsara poove.mp4"); MediaController mediaController=new MediaController(this); videoView.setMediaController(mediaController); } } |
See more
Comments
Post a Comment