通过与HTML5℃的流MP3文件求;音频&GT;标签 [英] Seeking through a streamed MP3 file with HTML5 <audio> tag
问题描述
我希望有人能帮助我了这一点。
Hopefully someone can help me out with this.
我与一个客户流音频的node.js服务器打过来,我想创建一个HTML5播放器。现在,我使用的是分块编码流从节点的code,如果你直接去URL,它的伟大工程。
I'm playing around with a node.js server that streams audio to a client, and I want to create an HTML5 player. Right now, I'm streaming the code from node using chunked encoding, and if you go directly to the URL, it works great.
我想要做的是这样使用HTML5嵌入&LT;音频&GT;
标签,就像这样:
What I'd like to do is embed this using the HTML5 <audio>
tag, like so:
<audio src="http://server/stream?file=123">
其中, /流
为节点服务器以流的MP3端点。 HTML5播放载荷Safari和Chrome很好,但它不允许我去追求,和Safari甚至说这是一个现场直播。在 /流
的头,我包括文件大小和文件类型,响应被正确地结束。
where /stream
is the endpoint for the node server to stream the MP3. The HTML5 player loads fine in Safari and Chrome, but it doesn't allow me to seek, and Safari even says it's a "Live Broadcast". In the headers of /stream
, I include the file size and file type, and the response gets ended properly.
这是我怎么能解决这个问题有什么想法?我当然可以只发送整个文件一次,但随后玩家会等到整个事情下载 - 我倒是而流呢
Any thoughts on how I could get around this? I certainly could just send the whole file at once, but then the player would wait until the whole thing is downloaded--I'd rather stream it.
推荐答案
请确保服务器接受范围请求,你可以检查是否接受-范围
是头。在jPlayer这是Webkit的(特别是铬)的一个常见问题的浏览器,当谈到进步和寻求功能。
Make sure the server accepts Range requests, you can check to see if Accept-Ranges
is in the header. In jPlayer this is a common issue in Webkit (particularly Chrome) browsers when it comes to progress and seeking functionality.
您可能没有使用jPlayer进行,但官方网站上的服务器响应信息可能会有些用处。
You might not be using jPlayer, but the Server Response information on the official website may be of some use.
http://www.jplayer.org/latest/developer -guide /#jPlayer服务器响应
这篇关于通过与HTML5℃的流MP3文件求;音频&GT;标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!