简体   繁体   English

HTML5音频流

[英]HTML5 Audio Streaming

There has been some talk of this around stackoverflow before, but nothing really answered this question from what I have seen. 之前有一些关于stackoverflow的讨论,但是从我看到的内容中没有真正回答这个问题。
I am trying to implement a streaming audio web application. 我正在尝试实现流式音频Web应用程序。 Almost identical to what WFMU has done with their player ( http://wfmu.org/html5/player.php ). 与WFMU对其玩家所做的几乎相同( http://wfmu.org/html5/player.php )。
All I have been able to figure out from their stream is they are piping the stream into PHP, don't know in what format, and then feeding this to jPlayer for HTML5 presentation to the client. 所有我能够从他们的流中弄清楚他们是将流传输到PHP,不知道以什么格式,然后将其提供给jPlayer以便HTML5呈现给客户端。
They have this working awesome, but I am just unsure how they are feeding the audio into PHP and what they are doing within their PHP to present it in an acceptable format for HTML5. 他们有这个工作真棒,但我只是不确定他们如何将音频提供给PHP以及他们在PHP中做了什么,以HTML5的可接受格式呈现它。
Any ideas would be greatly appreciated. 任何想法将不胜感激。
It looks like the PHP script just echos out an audio file ( http://blogfiles.wfmu.org/DG/stream3.php ). 看起来PHP脚本只是回声出一个音频文件( http://blogfiles.wfmu.org/DG/stream3.php )。

There is no requirement to use PHP. 没有要求使用PHP。 For the client, all that matters is you send the appropriate content type, and actual content. 对于客户来说,重要的是您发送适当的内容类型和实际内容。 In this case, audio/mpeg (MP3), or OGG for Firefox (which, isn't working for them right now, but it definitely can). 在这种情况下,音频/ mpeg(MP3),或Firefox的OGG(现在不适合他们,但它绝对可以)。

I suspect the reason that they are using PHP to relay the stream, is that they are using SHOUTcast as the streaming server. 我怀疑他们使用PHP来中继流的原因是他们使用SHOUTcast作为流媒体服务器。 Doing some poking around, I found this: http://mp3stream.wfmu.org:8000/ 做一些探讨,我发现了这个: http//mp3stream.wfmu.org8000 /

Note that when you hit that URL in your browser, you get the basic information page. 请注意,当您在浏览器中点击该URL时,您将获得基本信息页面。 However, if you hit this with an audio player, you get the stream. 但是,如果您使用音频播放器进行此操作,则会获得该流。 The SHOUTcast server decides this based on the User-Agent string. SHOUTcast服务器根据User-Agent字符串决定这一点。 If it contains "Mozilla" anywhere in the User-Agent, then it returns this page. 如果它在User-Agent中的任何位置包含“Mozilla”,则返回此页面。 If it doesn't, then it returns the stream. 如果没有,则返回流。 So, for an HTML5 audio player, it would use the browser's User-Agent (which contains Mozilla) and would be unable to access the stream. 因此,对于HTML5音频播放器,它将使用浏览器的User-Agent(包含Mozilla)并且无法访问该流。 I suspect their PHP script is what gets around the problem. 我怀疑他们的PHP脚本是解决问题的方法。

The PHP script would use cURL, connect to the streaming server with its own User-Agent (can be anything, as long as it isn't "Mozilla"), and relay chunk by chunk to the browser that hit the PHP script. PHP脚本将使用cURL,使用自己的User-Agent连接到流服务器(可以是任何东西,只要它不是“Mozilla”),并通过chunk将块传递到访问PHP脚本的浏览器。 Piece of key-lime-pie. 一块关键的石灰馅饼。

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

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