你好我想播放,暂停和停止我的视频,但似乎无法做到这一点。看看下面的代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_LEFT_ICON);
setContentView(R.layout.iworkout);
getWindow().setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.exercises32);
vv = (VideoView) findViewById (R.id.vv_Exercise);
play = (Button) findViewById (R.id.btWorkOutPlay);
pause = (Button) findViewById (R.id.btWorkOutPause);
stop = (Button) findViewById (R.id.btWorkOutStop);
}
public void onClick(View v) {
// TODO Auto-generated method stub
switch(v.getId()){
case R.id.btWorkOutPlay:
Uri uri = Uri.parse("android.resource://"+getPackageName()+"/"+R.raw.exercise1);
vv.start();
vv.setVideoURI(uri);
break;
case R.id.btWorkOutPause:
vv.pause();
break;
case R.id.btWorkOutStop:
vv.stopPlayback();
break;
}
} // end of onClick method
如果有人知道该怎么做,我将非常感谢你的帮助。感谢。
答案 0 :(得分:3)
将MediaController
与VideoView
:
....
MediaController mc= new MediaController();
Videoview.setMediaController(mc);
....