我有一個應用程序,使播放按鈕的視頻列表。當我點擊播放按鈕時,一個單獨的活動就開始使用意圖。我只是希望當視頻播放完成時,活動應該自動完成,並返回到主Activity。這是我創建videoview的代碼。如何回放後播放視頻
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
setContentView(R.layout.videoview);
Intent i = getIntent();
Bundle extras = i.getExtras();
filename = extras.getString("videofilename");
mVideoView = (VideoView)findViewById(R.id.videoview);
path=filename;
if (path == "") {
Toast.makeText(
ViewVideo.this,
"no video selected,
Toast.LENGTH_LONG).show();
} else {
mVideoView.setVideoPath(path);
mc = new MediaController(this);
mVideoView.setMediaController(mc);
mVideoView.requestFocus();
mVideoView.start();
}
}
任何建議???
能否請您詳細一點多;我對android很陌生。如果您告訴我如何在視頻播放器上註冊onCompletionListener,我將非常感激。謝謝 – Farhan
Upadted answer。 – MByD
我試過它先生,並使用Log.v()和完成()以及看看這個函數是否被調用,但它沒有被調用..你能告訴我先生在哪裏把這個代碼在我的代碼..我可能會把它放在錯誤的地方.. – Farhan