HTML5音频流 [英] HTML5 Audio Streaming

查看:142
本文介绍了HTML5音频流的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以前有人对此进行了一些讨论,但没有真正从我所见过的这个问题回答。

我试图实现流式音频web应用程序。几乎与WFMU对他们的玩家所做的一样( http://wfmu.org/html5/player.php )。

所有我已经能够从他们的流中找出他们正在将流传输到PHP中,不知道以何种格式,然后将其馈送给jPlayer,以便将HTML5呈现给客户端。

他们有这个工作真棒,但我只是不确定他们是如何将音频输入到PHP以及他们在PHP中做什么,以HTML5的可接受格式呈现它。

任何想法将不胜感激。

看起来PHP脚本只是回显了一个音频文件( http:/ /blogfiles.wfmu.org/DG/stream3.php )。

There has been some talk of this around stackoverflow before, but nothing really answered this question from what I have seen.
I am trying to implement a streaming audio web application. Almost identical to what WFMU has done with their player (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.
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.
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 。对于客户来说,重要的是您发送适当的内容类型和实际内容。在这种情况下,音频/ mpeg(MP3)或Firefox的OGG(现在不适用于它们,但它绝对可以)。

There is no requirement to use 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).

我怀疑他们使用PHP来中继流的原因是他们使用SHOUTcast作为流媒体服务器。做了一些探讨,我发现了这个: http://mp3stream.wfmu.org:8000/

I suspect the reason that they are using PHP to relay the stream, is that they are using SHOUTcast as the streaming server. Doing some poking around, I found this: http://mp3stream.wfmu.org:8000/

请注意,当您在浏览器中点击该网址时,您会看到基本信息页面。但是,如果您使用音频播放器进行播放,则会获得流媒体。 SHOUTcast服务器根据User-Agent字符串决定这一点。如果它包含用户代理中任何地方的Mozilla,则它返回此页面。如果没有,则返回流。因此,对于HTML5音频播放器,它将使用浏览器的User-Agent(包含Mozilla)并且无法访问该流。我怀疑他们的PHP脚本是解决问题的方法。

Note that when you hit that URL in your browser, you get the basic information page. However, if you hit this with an audio player, you get the stream. The SHOUTcast server decides this based on the User-Agent string. If it contains "Mozilla" anywhere in the User-Agent, then it returns this page. 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. I suspect their PHP script is what gets around the problem.

PHP脚本将使用cURL,使用自己的User-Agent连接到流服务器(可以是任何东西,只要它不是Mozilla),然后通过块将块传递给碰到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. Piece of key-lime-pie.

这篇关于HTML5音频流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆