Media player class can be used to control playback of audio/video files and streams.An example below is shows how to use and play a video .
the following code will be useful:
package com.codingonandroid;
import android.app.Activity;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;
public class VideoplayerActivity extends Activity {
VideoView vv;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
vv=(VideoView)findViewById(R.id.videoView1);
vv.setVideoPath("/sdcard/dh.3gp");
vv.setMediaController(new MediaController(this));
vv.start();
}
}
//.xml file will be:
<VideoView
android:id="@+id/videoView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
the following code will be useful:
package com.codingonandroid;
import android.app.Activity;
import android.os.Bundle;
import android.widget.MediaController;
import android.widget.VideoView;
public class VideoplayerActivity extends Activity {
VideoView vv;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
vv=(VideoView)findViewById(R.id.videoView1);
vv.setVideoPath("/sdcard/dh.3gp");
vv.setMediaController(new MediaController(this));
vv.start();
}
}
//.xml file will be:
<VideoView
android:id="@+id/videoView1"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
No comments:
Post a Comment