我一定是在缺少明显的东西在这里,但我似乎无法找到任何东西,让我来决定何时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.