Android的显示图像,同时视频缓冲? [英] Android Show image while video is buffering?

查看:241
本文介绍了Android的显示图像,同时视频缓冲?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有使用VideoView显示视频的应用程序。布局由一个时钟和一个简单的垂直的LinearLayout制定了一个VideoView的。

I have an app that displays a video using VideoView. The layout consists of a Clock and a VideoView laid out in a simple vertical LinearLayout.

下面是我的code片段,我使用:

Here's my code snippet that I use:

VideoView mVideoView = new VideoView(this);
mVideoView.setVideoPath(myVideoURL);
mVideoView.requestFocus();
mVideoView.start();

由于视频的缓冲时间约8-10秒,布局出现与时钟,但VideoView保持空白。我想实现的是:

Since the buffering of the video takes about 8-10 seconds, the layout comes up with the Clock, but the VideoView stays blank. What I want to achieve is this:

- 显示为10秒的ImageView的,而视频缓冲
- 检测在视频准备播放(在prepared?)
- 显示时钟和VideoView,并开始视频

-- Display an ImageView for the 10s while the video is buffering -- Detect when the video is ready to be played (onPrepared?) -- Show the Clock and VideoView and start the Video

任何人有如何去这个指针?

Anyone have pointers on how to go about this?

谢谢
克里斯

推荐答案

的MediaPlayer就会让你注册一个的在preparedListener 回调,你可以用它来确定当视频准备开始。所以,你会先显示您的ImageView,而不是你VideoView,那么当你的回调函数被调用,切换到VideoView,并开始播放。

MediaPlayer will let you register an OnPreparedListener callback which you can use to determine when the video is ready to be started. So you would show your ImageView instead of your VideoView first, then when your callback gets called, change to the VideoView and start playing.

这篇关于Android的显示图像,同时视频缓冲?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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