急求: android怎么对mpg格式视频实现在线播放???
对于3GP格式的视频都直接可以进行播放,但是对mpg格式谈话对话框提示无法播放此视频。是不是mpg格式的还需要我特别进行格式转化呢?
播放视频使用的控件是VideoView。
public class MediaActivity extends Activity {
public static final String TAG = "VideoPlayer";
private VideoView mVideoView;
private Uri mUri;
private int mPositionWhenPaused = -1;
private MediaController mMediaController;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_media);
//Set the screen to landscape.
this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
mVideoView = (VideoView)findViewById(R.id.video_view);
//Video file
// mUri = Uri.parse(Environment.getExternalStorageDirectory() + "/1.3gp");
// mUri=Uri.parse("http://daily3gp.com/vids/family_guy_penis_car.3gp");
mUri = Uri.parse("http://www.nuoter.com/qingnianjiwang.mpg");
//Create media controller,组件可以控制视频的播放,暂停,回复,seek等操作,不需要你实现
mMediaController = new MediaController(this);
mVideoView.setMediaController(mMediaController);
}
public void onStart() {
// Play Video
mVideoView.setVideoURI(mUri);
mVideoView.start();
super.onStart();
}
public void onPause() {
// Stop video when the activity is pause.
mPositionWhenPaused = mVideoView.getCurrentPosition();
mVideoView.stopPlayback();
super.onPause();
}
public void onResume() {
// Resume video player
if(mPositionWhenPaused >= 0) {
mVideoView.seekTo(mPositionWhenPaused);
mPositionWhenPaused = -1;
}
super.onResume();
}
public boolean onError(MediaPlayer player, int arg1, int arg2) {
return false;
}