我在imageview的並且videoview顯示圖像和視頻,但問題是當視頻是 打onpreparedlistener調用,但是當視頻完成oncompletion聽者不叫 時videoview完全i遞增爲下一個視頻或圖像videoview oncompletionlistener未在android中調用?
也是它的我給我的錯誤在這樣但視頻logcat的播放
10-29 20:12:47.770:E/MediaPlayer的(3975):錯誤(1,-2147483648)
private void nextVideo(String path){
mImageview.setVisibility(View.GONE);
if(mVideoview.getVisibility()==View.GONE){
mVideoview.setVisibility(View.VISIBLE);
}
controller = new MediaController(HomeActivityNewViewPager.this);
mVideoview.setVideoURI(Uri.parse(path));
mVideoview.setMediaController(null);
controller.setMediaPlayer(mVideoview);
mVideoview.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
mVideoview.start();
long duration = mVideoview.getDuration();
second=duration;
//handler.removeCallbacks(runnable);
//handler.postDelayed(runnable,second);
}
});
mVideoview.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
Log.v("video view completed","---"+i);
mp.reset();
if(automode){
if(i==myplaylistlocal.size() || i>myplaylistlocal.size())
{
String checkcount=spreferences.getString("roundcount", "");
Log.v("roundcount==Before Integer.parseInt","---->"+roundcount);
if(roundcount>=Integer.parseInt(checkcount))
{
roundcount=0;
Log.v("roundcount==After Integer.parseInt","---->"+roundcount);
updateplaylist();
}
i=0;
indexplus();
imagesautomode();
i++;
}
else if(i==myplaylistlocal.size()-1)
{
imagesautomode();
i++;
}
else{
imagesautomode();
}
}
else{
i++;
images();
}
}
});
mVideoview.setOnErrorListener(new OnErrorListener() {
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
Log.v("Error in video playing","----->"+i);
return true;
}
});
}
你得到任何錯誤,從視頻播放器了?有些代碼可能是不正確的格式等。我注意到一些視頻編碼不正確,並在視頻播放器認爲他們完成之前結束。 – 2014-10-29 14:48:39
10-29 20:12:47.770:E/MediaPlayer(3975):錯誤(1,-2147483648)這是顯示在logcat中,但仍然onerrorlistner不叫 – Mahesh 2014-10-29 14:56:01