下面是我的代码。 我的视频视图每次你按住主控按钮/ 按下主控按钮时都会重新启动。 是否有任何办法可以让我在按住主控按钮前继续播放我的视频。
编辑:我已经在Bharat提到的代码中输入了代码。但似乎我犯了错误,但是没有解决。
public class Video1 extends Activity {
private MediaController mc;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.videomain);
//AdView adView = (AdView)this.findViewById(R.id.adView);
//adView.loadAd(new AdRequest());
VideoView vd = (VideoView) findViewById(R.id.VideoView);
Uri uri = Uri.parse("android.resource://" + getPackageName() + "/" + R.raw.opening);
mc = new MediaController(this);
vd.setMediaController(mc);
vd.setVideoURI(uri);
vd.start();
vd.setOnCompletionListener(new MediaPlayer.OnCompletionListener()
{
public void onCompletion(MediaPlayer mp)
{
Intent intent=new Intent(Video1.this,GalleryVideo.class);
startActivity(intent);
}
});
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
@Override
protected void onPause() {
vd.pause(); /**ERROR - vd cannot be resolved**/
super.onPause();
}
@Override
protected void onResume() {
vd.resume(); /**ERROR - vd cannot be resolved**/
super.onResume();
}
}