Android的VideoView不打连续的视频 [英] Android VideoView not playing sequential videos

查看:1115
本文介绍了Android的VideoView不打连续的视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要玩2视频成一排。第一视频始终发挥就好了。它完成后,您可以在日志中看到,这台新的视频网址,但随后SurfaceView抛出一个错误,并且VideoView只是冻结与第一视频的最后一帧。没有什么事情发生。 有什么想法吗 ?谢谢!

LE:令人惊讶地,在preparedListener被调用用于第二视频

LE2:有时候秒的视频播放就好了,有时不...我也没变线code,当它工作时不间。这是纯粹的随机...

LE3:快速的解决办法是,然后再设置新的视频网址加入这一行:

  mVideoView.setVisibility(View.GONE);
 

从OnCompletionListener code:

  setCurrentPlaybackUrl(); //设置mCurrentMediaUrl到第二视频网址
mVideoView.setVideoPath(mCurrentMediaUrl);
mVideoView.start();
 

这是日志输出,当第一视频完成播放:

  12月10日至22日:32:35.762:I / AwesomePlayer(126):setDataSource_l(将https://xx/TestingVideo_lo.mp4)
12月10号至22日:32:35.762:E / BufferQueue(123):[SurfaceView]连接:已连接(CUR = 3,REQ = 3)
12月10号至22日:32:35.762:E / MediaPlayerService(126):setVideoSurfaceTexture失败:-22
12月10号至22日:32:35.762:E / BufferQueue(123):[SurfaceView]连接:已连接(CUR = 3,REQ = 3)
12月10号至22日:32:35.762:E / MediaPlayerService(126):setVideoSurfaceTexture失败:-22
 

解决方案

尝试对 onCompletion(MediaPlayer的MP),添加 mp.stop (),然后做你的东西。

编辑:我曾尝试这样做,它的工作:

  videoView.setOnCompletionListener(新MediaPlayer.OnCompletionListener(){
@覆盖
公共无效onCompletion(MediaPlayer的MP){
       play_video();
}
});

play_video();
 

其中, play_video 是下面的方法:

 无效play_video(){
    开放的我们的uri = Uri.parse(VIDEO_LINK);
    videoView.setVideoURI(URI);
    videoView.requestFocus();
    videoView.setVisibility(View.VISIBLE);
    videoView.start();

 }
 

唯一的区别是,我发挥相同的视频两次,而不是两个不同的视频。

I want to play 2 videos in a row. The first video always plays just fine. After it finishes, you can see in the log that it sets the new video URL, but then SurfaceView throws an error and the VideoView just freezes with the last frame of the first video. Nothing else happens. Any thoughts ? Thanks !

LE: Surprisingly, the OnPreparedListener gets called for the second video.

LE2: Sometimes the second video plays just fine, sometimes it doesn't... and I haven't changed a line of code between when it worked and when not. It's purely random...

LE3: Quick solution is add this line before you set the new video URL:

mVideoView.setVisibility(View.GONE);

Code from OnCompletionListener:

setCurrentPlaybackUrl(); // sets mCurrentMediaUrl to the second video URL
mVideoView.setVideoPath(mCurrentMediaUrl);
mVideoView.start();

This is the log output when the first video finishes playback:

10-22 12:32:35.762: I/AwesomePlayer(126): setDataSource_l('https://xx/TestingVideo_lo.mp4')
10-22 12:32:35.762: E/BufferQueue(123): [SurfaceView] connect: already connected (cur=3, req=3)
10-22 12:32:35.762: E/MediaPlayerService(126): setVideoSurfaceTexture failed: -22
10-22 12:32:35.762: E/BufferQueue(123): [SurfaceView] connect: already connected (cur=3, req=3)
10-22 12:32:35.762: E/MediaPlayerService(126): setVideoSurfaceTexture failed: -22

解决方案

Try on the onCompletion(MediaPlayer mp) , to add mp.stop() and then do your stuff .

EDIT: I have tried this and it's working:

videoView.setOnCompletionListener(new MediaPlayer.OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
       play_video();
}
});

play_video();

where play_video is the following method :

void play_video() {
    Uri uri = Uri.parse(video_link);
    videoView.setVideoURI(uri);    
    videoView.requestFocus();
    videoView.setVisibility(View.VISIBLE);
    videoView.start();

 }

The only difference is that I played the same video twice, not two different videos.

这篇关于Android的VideoView不打连续的视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆