我正在将 Javascript 用于广播播放器,因此,有时有人网络不好并且连接中断,我想知道是否有类似缓冲的功能,以便在崩溃时重新加载流。
希望有人能解答,谢谢。
问候,
Julia 。
最佳答案
如果您的用例是 radio ,则数据正在流式传输,因此您无法访问过去的数据,如果用例只是媒体播放器,则可以使用 buffered
要查询的音频元素的属性是当前缓冲的媒体范围或currentTime
访问当前执行时间的属性。
var myAudioElement = document.createElementbyTag('audio')
// let's suppose that the audio element has a radio streaming attached as source
myAudioElement.buffered // returns the last data that has been downloaded from the source
myAudioElement.currentTime // returns the time of the last data played
也许你应该看到类似 connection API了解您的用户何时下线
关于javascript - 缓冲音频源,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31047777/