大家好我有一個視頻集在我的應用程序中作爲背景。當應用程序啓動主菜單中的視頻播放時,一切正常。現在,當我選擇進入下一個活動時,視頻停止和下一個活動開始,當用戶完成此活動並按下後退按鈕以轉到主菜單時,視頻應該再次播放,但它不會「噸。希望有人能幫助我。這裏是我的代碼:當按下後退按鈕時播放視頻
public class MainActivity extends Activity {
VideoView animation;
private MediaController mc;
MediaPlayer mp;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mp = MediaPlayer.create(this, R.raw.leftbanktwo);
mp.setLooping(true);
VideoView animation = (VideoView) findViewById(R.id.imageAnimation);
Uri uri = Uri.parse("android.resource://" + getPackageName() + "/"+R.raw.cartoon);
mc = new MediaController(this);
animation.setMediaController(mc);
animation.requestFocus();
animation.setVideoURI(uri);
animation.start();
}
感謝,似乎已經解決了我的問題! – Allrounder