首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何多次使用Vitamio VideoView?

如何多次使用Vitamio VideoView?
EN

Stack Overflow用户
提问于 2014-09-12 13:07:59
回答 1查看 1.6K关注 0票数 1

我正在使用Vitamio库,需要每分钟播放一段简短的视频。有一段时间,它的工作很好,但在几次执行后,Vitamio开始显示一个空白的屏幕,而不是播放视频。在这种情况下,本机VideoView工作得很好,但我需要支持更多的视频格式。

这是视频显示的Vitamio日志:

代码语言:javascript
复制
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

如果不是的话:

代码语言:javascript
复制
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

下面是我的启动视频的代码片段:

代码语言:javascript
复制
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?这并没有改变什么:

代码语言:javascript
复制
mVideoView = null;
mVideoView = (VideoView) findViewById(R.id.videoViewForAdv);    
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-09-12 17:07:07

我找到了解决问题的办法。我刚把Vitamio VideoView改成Vitamio MediaPlayer。现在一切都很好。下面是播放视频的结果代码:

代码语言:javascript
复制
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();
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25809072

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档