使用VideoView缓冲视频(Buffering videos with VideoView)

编程入门 行业动态 更新时间:2024-10-28 02:21:27
使用VideoView缓冲视频(Buffering videos with VideoView)

我有一个活动,它需要一个网址并使用VideoView播放视频。 这很好用。

但是,视频开始播放前有一段缓冲时间。 因此,VideoView是黑色的。 没有指示缓冲区加载的微调器。

VideoView的参数是否会显示微调器? 如果没有,是否有一些消息在视频开始播放时被广播? 这样我就可以显示自己的微调器并在收到消息时隐藏它。

I have an Activity that takes a url and plays the video with a VideoView. This works fine.

However, there is a buffer time before the video starts playing. Because of this, the VideoView is black. There is no spinner indicating a buffer loading.

Is there a parameter of the VideoView that will show a spinner? If not, is there some message that gets broadcast when the video starts playing? That way I can show my own spinner and hide it when the message is received.

最满意答案

我找到了答案。 在VideoView顶部添加ProgressBar并执行以下操作:

mPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { mSpinner.setVisibility(View.GONE); } });

I've found the answer. Add a ProgressBar over the top of the VideoView and do the following:

mPlayer.setOnPreparedListener(new MediaPlayer.OnPreparedListener() { @Override public void onPrepared(MediaPlayer mp) { mSpinner.setVisibility(View.GONE); } });

更多推荐

本文发布于:2023-08-05 05:48:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1428653.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:视频   VideoView   videos   Buffering

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!