我正在使用Vitamio库,需要每分钟播放一段短片。 有一段时间它工作得很好,但在几次执行后,Vitamio开始显示空白屏幕而不是播放视频。 Native Video在这种情况下效果很好,但我需要支持更多的视频格式。
以下是视频显示时的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 :(得分: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();
}