Android的 - 如何知道什么时候MediaPlayer正在缓冲 [英] Android - How to tell when MediaPlayer is buffering

查看:872
本文介绍了Android的 - 如何知道什么时候MediaPlayer正在缓冲的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一定是在缺少明显的东西在这里,但我似乎无法找到任何东西,让我来决定何时MediaPlayer的是缓冲音频。我在互联网流媒体音频和我想显示一个缓冲的指标,但没有我试图让我知道什么时候中断的MediaPlayer的音频缓冲,所以我不能正常显示缓冲指标。任何线索?

I've got to be missing something obvious here, but I can't seem to find anything to allow me to determine when MediaPlayer is buffering audio. I'm streaming internet audio and I want to display a buffering indicator, but nothing I've tried allows me to know when MediaPlayer interrupts the audio to buffer, so I can't properly display a buffering indicator. Any clues?

推荐答案

@Daniel,每对@ JRL的回答您的评论,你很可能得到这个工作,通过旋转一个线程,并等待超时。

@Daniel, per your comment on @JRL's answer, you could probably get this working by spinning up a thread and waiting for a timeout.

喜欢的东西 DetectBufferTimeout.java (未经测试)会做很好。

Something like DetectBufferTimeout.java (untested) would do nicely.

我做的,但是,一致认为,纺了这个单独的线程是一个黑客攻击的一位。也许 OnBufferingUpdateListener 可以做出保证,如何往往要求 onBufferingUpdate()无论是否处于缓冲进度的变化已经发生,所以我们可以发现,如果我们得到了相同的数值一遍又一遍。

I do, however, agree that spinning up this separate thread is a bit of a hack. Perhaps OnBufferingUpdateListener could make a guarantee as to how often it calls onBufferingUpdate() regardless of whether a change in the buffering progress has occurred so we can detect if we're getting the same value over and over.

这篇关于Android的 - 如何知道什么时候MediaPlayer正在缓冲的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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