2014-09-12 62 views
1

我正在使用Vitamio圖書館,並且需要每分鐘播放一段短片。 有一段時間它工作得很好,但經過幾次處決之後,Vitamio開始顯示空白屏幕而不是播放視頻。原生VideoView在這種情況下效果很好,但我需要支持更多的視頻格式。如何多次使用Vitamio VideoView?

這裏的視頻時顯示Vitamio日誌:

09-12 15:30:35.683 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ VPLAYER INIT BEGIN 
09-12 15:30:35.683 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ Application package name: com.test.testhtmlbuttons 
09-12 15:30:35.693 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ VPLAYER INIT END 
09-12 15:30:35.693 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ Copyright (c) YIXIA (http://yixia.com). 
    THIS SOFTWARE (Vitamio) IS WORK OF YIXIA (http://yixia.com) 
09-12 15:30:35.693 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ Application package name: com.test.testhtmlbuttons 
09-12 15:30:35.693 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ Copyright (c) YIXIA (http://yixia.com). 
    THIS SOFTWARE (Vitamio) IS WORK OF YIXIA (http://yixia.com) 
09-12 15:30:35.693 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ Application package name: com.test.testhtmlbuttons 
09-12 15:30:35.693 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ PREPARE SIG: 0 
09-12 15:30:35.693 26713-26747/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ THREAD PREPARE START 
09-12 15:30:35.693 26713-26747/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ THREAD PREPARE ATTACHED 
09-12 15:30:35.703 26713-26747/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ Copyright (c) YIXIA (http://yixia.com). 
    THIS SOFTWARE (Vitamio) IS WORK OF YIXIA (http://yixia.com) 
09-12 15:30:35.703 26713-26747/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ OPEN FILE /mnt/sdcard/Android/Data/com.test.simdisplay/adv/FILE.mp4 
09-12 15:30:35.803 26713-26747/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ META AUDIO: , META SUBTITLE: 
09-12 15:30:35.803 26713-26747/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ Copyright (c) YIXIA (http://yixia.com). 
    THIS SOFTWARE (Vitamio) IS WORK OF YIXIA (http://yixia.com) 
09-12 15:30:35.803 26713-26747/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ Application package name: com.test.testhtmlbuttons 
09-12 15:30:35.803 26713-26747/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ WOW: BRILLIANT C COUNT 4 
09-12 15:30:35.813 26713-26747/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ OPEN STREAM VIDEO BEGIN 
09-12 15:30:35.813 26713-26747/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ OPEN STREAM VIDEO END 
09-12 15:30:35.813 26713-26747/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ DEMUX SIG: 0 
09-12 15:30:35.813 26713-26747/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ THREAD PREPARE DETTACHED, ret = 0 
09-12 15:30:35.813 26713-26747/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ THREAD PREPARE END 
09-12 15:30:35.813 26713-26752/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ CC: ARMYUV420 0 
09-12 15:30:35.813 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ start 
09-12 15:30:35.813 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ stop 
09-12 15:30:35.873 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ start 
09-12 15:30:35.953 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ start 
09-12 15:30:42.343 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ stop 
09-12 15:30:42.373 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ start 
09-12 15:30:47.523 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ stop 
09-12 15:30:47.543 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ start 
09-12 15:30:50.613 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ stop 
09-12 15:30:50.613 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ VPLAYER RELEASE BEGIN 
09-12 15:30:50.613 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ prepare pthread_cancel/pthread_kill 3 
09-12 15:30:50.613 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ prepare pthread_join 0 
09-12 15:30:50.613 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ demux pthread_kill 0 
09-12 15:30:50.623 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ demux pthread_join 0 
09-12 15:30:50.623 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ FILE CLOSE BEGIN 
09-12 15:30:50.623 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ CLOSE STREAM VIDEO BEGIN 
09-12 15:30:50.623 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ CLOSE STREAM VIDEO END 
09-12 15:30:50.633 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ CLOSE AVFORMAT BEGIN 
09-12 15:30:50.633 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ CLOSE AVFORMAT END 
09-12 15:30:50.633 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ FREE VIDEOPIC BEGIN 
09-12 15:30:50.633 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ FREE VIDEOPIC 2 END 
09-12 15:30:50.633 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ FREE SUBPIC BEGIN 
09-12 15:30:50.633 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ FREE SUBPIC 1 END 
09-12 15:30:50.633 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ FREE AUDIOFRAME BEGIN 
09-12 15:30:50.633 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ FREE AUDIOFRAME 8 END 
09-12 15:30:50.633 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ DELETE GLOBAL REF BEGIN 
09-12 15:30:50.633 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ DELETE GLOBAL REF END 
09-12 15:30:50.633 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ FILE CLOSE END 
09-12 15:30:50.713 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ VPLAYER RELEASE END 
09-12 15:30:50.763 26713-26715/com.test.testhtmlbuttons D/dalvikvm﹕ GC_CONCURRENT freed 435K, 10% free 4313K/4776K, paused 3ms+2ms, total 18ms 
09-12 15:30:50.763 26713-26722/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ NATIVE FINALIZE VPLAYER 
09-12 15:30:50.763 26713-26722/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ NATIVE FINALIZE VPLAYER END 

而且,當它不是:

09-12 15:36:50.313 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ VPLAYER INIT BEGIN 
09-12 15:36:50.313 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ Application package name: com.test.testhtmlbuttons 
09-12 15:36:50.313 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ VPLAYER INIT END 
09-12 15:36:50.313 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ Copyright (c) YIXIA (http://yixia.com). 
    THIS SOFTWARE (Vitamio) IS WORK OF YIXIA (http://yixia.com) 
09-12 15:36:50.313 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ Application package name: com.test.testhtmlbuttons 
09-12 15:36:50.323 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ Copyright (c) YIXIA (http://yixia.com). 
    THIS SOFTWARE (Vitamio) IS WORK OF YIXIA (http://yixia.com) 
09-12 15:36:50.323 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ Application package name: com.test.testhtmlbuttons 
09-12 15:36:50.323 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ PREPARE SIG: 0 
09-12 15:36:50.323 26713-26908/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ THREAD PREPARE START 
09-12 15:36:50.323 26713-26908/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ THREAD PREPARE ATTACHED 
09-12 15:36:50.323 26713-26908/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ Copyright (c) YIXIA (http://yixia.com). 
    THIS SOFTWARE (Vitamio) IS WORK OF YIXIA (http://yixia.com) 
09-12 15:36:50.323 26713-26908/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ OPEN FILE /mnt/sdcard/Android/Data/com.test.simdisplay/adv/FILE.mp4 
09-12 15:36:50.333 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ prepare pthread_cancel/pthread_kill 0 
09-12 15:36:50.333 26713-26908/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ THREAD PREPARE DETTACHED, ret = 0 
09-12 15:36:50.333 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ prepare pthread_join 0 
09-12 15:36:50.333 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ FILE CLOSE BEGIN 
09-12 15:36:50.333 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ CLOSE AVFORMAT BEGIN 
09-12 15:36:50.333 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ CLOSE AVFORMAT END 
09-12 15:36:50.333 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ FREE VIDEOPIC BEGIN 
09-12 15:36:50.333 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ FREE VIDEOPIC 2 END 
09-12 15:36:50.333 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ FREE SUBPIC BEGIN 
09-12 15:36:50.333 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ FREE SUBPIC 1 END 
09-12 15:36:50.333 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ FREE AUDIOFRAME BEGIN 
09-12 15:36:50.333 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ FREE AUDIOFRAME 8 END 
09-12 15:36:50.333 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ DELETE GLOBAL REF BEGIN 
09-12 15:36:50.333 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ DELETE GLOBAL REF END 
09-12 15:36:50.333 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ FILE CLOSE END 
09-12 15:36:50.343 26713-26715/com.test.testhtmlbuttons D/dalvikvm﹕ GC_CONCURRENT freed 387K, 11% free 4316K/4840K, paused 3ms+2ms, total 22ms 
09-12 15:36:50.413 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ VPLAYER RELEASE BEGIN 
09-12 15:36:50.413 26713-26713/com.test.testhtmlbuttons I/Vitamio[4.2.6][Player]﹕ VPLAYER RELEASE END 

這裏是我的代碼片段開始視頻:

if(mVideoView.isPlaying()) { 
    mVideoView.stopPlayback(); 
    mVideoView.destroyDrawingCache(); 
} 
mVideoView.setVisibility(View.VISIBLE); 
mVideoView.setVideoPath(path); 
mVideoView.setVideoQuality(MediaPlayer.VIDEOQUALITY_HIGH); 
mVideoView.setMediaController(null); 
mVideoView.requestFocus(); 
mVideoView.start(); 

有沒有人面臨這樣的問題?如何正確釋放所有Vitamio資源並重新使用VideoView? 這不會改變:

mVideoView = null; 
mVideoView = (VideoView) findViewById(R.id.videoViewForAdv);  

回答

0

我找到了解決我的問題的方法。 我剛將Vitamio VideoView更改爲Vitamio MediaPlayer。現在一切正常。 這裏是我的播放視頻的結果代碼:

releaseMediaPlayer(); 
try { 
    mMediaPlayer = new MediaPlayer(getApplicationContext()); 
    mMediaPlayer.setDataSource(path); //Path to video file 
    mMediaPlayer.setDisplay(holder); //Set SurfaceHolder 
    mMediaPlayer.prepare(); 
    mMediaPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { 
     @Override 
     public void onPrepared(MediaPlayer mp) { 
      startVideoPlayback(); 
     } 
    }); 
} 
catch (Exception e){} 

... 

private void releaseMediaPlayer() { 
    if (mMediaPlayer != null) { 
     if(mMediaPlayer.isPlaying()) 
      mMediaPlayer.stop(); 
     mMediaPlayer.release(); 
     mMediaPlayer = null; 
    } 
} 

private void startVideoPlayback() { 
    holder.setSizeFromLayout(); 
    mMediaPlayer.start(); 
}