简体   繁体   English

停止使用Buzz将流音频下载到HTML5元素

[英]Stop download of streaming audio to HTML5 element with Buzz

I am using Buzz to abstract HTML5 audio for internet radio. 我正在使用Buzz为互联网广播提取HTML5音频。 This works well, but I need a way to stop downloading the stream when audio is stopped. 效果很好,但是我需要一种在音频停止后停止下载流的方法。

For example, when I start playing, I can see the network requests for the stream begin. 例如,当我开始播放时,我可以看到对该流的网络请求开始。 When I stop audio, that data for the stream is still being transferred, as if it were a static resource. 当我停止音频时,流的数据仍在传输,就好像它是静态资源一样。 I need to either prevent that from happening, or get it to stop once audio is stopped. 我需要防止这种情况的发生,或者在音频停止后将其停止。

I believe jPlayer does this by destroying the <audio> element, but I don't see any method for doing this in Buzz. 我相信jPlayer会通过破坏<audio>元素来做到这一点,但我在Buzz中看不到任何实现此目的的方法。 Is it possible? 可能吗? If so, how? 如果是这样,怎么办?

After spending some time with the Buzz source, I don't see any method for doing this currently. 在花了一些时间访问Buzz源之后,我目前看不到任何执行此操作的方法。 Fortunately, the raw audio element is exposed, allowing something like this: 幸运的是,原始音频元素已公开,允许执行以下操作:

buzz.sound.prototype.destroy = function () {
    this.set('src', '');
}

This probably messes up some internal state information for Buzz. 这可能会弄乱Buzz的一些内部状态信息。 I'm looking into that right now. 我现在正在调查。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM