Html 是否可以使用 html5 播放 Shotcast Internet 广播流?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2229118/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Is it possible to play shoutcast internet radio streams with html5?
提问by Rella
Is it possible to play shoutcast (or some) internet radio streams with html5?
是否可以使用 html5 播放shoutcast(或某些)互联网广播流?
So I have next code:
所以我有下一个代码:
<html>
<body>
<audio src="http://shoutcast.internet-radio.org.uk:10272/" />
</body>
</html>
I save it as HTML page and start my browser (Google chrome 4.0.249.78, safary or FF)
我将其保存为 HTML 页面并启动浏览器(Google chrome 4.0.249.78、safary 或 FF)
But it does not play/work!(
但它不播放/工作!(
And it does not play with any other internet radio I tried to play!(
它不能与我尝试播放的任何其他网络电台一起播放!(
Why!?! What am I doing wrong?
为什么!?!我究竟做错了什么?
btw: from HTML5 (including next generation additions still in development) 2.6.1 Protocol conceptsUser agents can implement a variety of transfer protocols, but this specification mostly defines behavior in terms of HTTP. [HTTP]
btw:来自HTML5(包括仍在开发中的下一代添加) 2.6.1 协议概念用户代理可以实现多种传输协议,但该规范主要根据 HTTP 定义行为。[HTTP]
The HTTP GET method is equivalent to the default retrieval action of the protocol. For example, RETR in FTP. Such actions are idempotent and safe, in HTTP terms.
HTTP GET 方法等效于协议的默认检索操作。例如,FTP 中的 RETR。在 HTTP 术语中,此类操作是幂等且安全的。
The HTTP response codes are equivalent to statuses in other protocols that have the same basic meanings. For example, a "file not found" error is equivalent to a 404 code, a server error is equivalent to a 5xx code, and so on.
HTTP 响应码相当于其他协议中具有相同基本含义的状态。例如,“找不到文件”错误相当于 404 代码,服务器错误相当于 5xx 代码,等等。
The HTTP headers are equivalent to fields in other protocols that have the same basic meaning. For example, the HTTP authentication headers are equivalent to the authentication aspects of the FTP protocol.
HTTP 标头相当于其他协议中具有相同基本含义的字段。例如,HTTP 身份验证标头等效于 FTP 协议的身份验证方面。
采纳答案by Yahoo
You can't do it with ShoutCast but with Icecast and edcast client you can stream live vorbis trough HTML5 <audio>
tag. Just point it to http://your-url.com:port/stream.ogg:p
你不能用 ShoutCast 做到这一点,但是用 Icecast 和 edcast 客户端你可以通过 HTML5<audio>
标签流式传输实时 vorbis 。只需将其指向http://your-url.com:port/stream.ogg:p
回答by Nate Sweet
Add a semicolon to the end of the http
request. It IS the protocol set forth by shoutcast to override its browser detection. Like this example:
在http
请求的末尾添加分号。这是 Shotcast 提出的协议,用于覆盖其浏览器检测。像这个例子:
<audio controls src="http://shoutcast.internet-radio.org.uk:10272/;"></audio>
回答by Brian Campbell
HTML5 doesn't specify what audio formats (whether progressive or streaming) the player must support. That's up for the browser to determine, based on demand and implementation feasibility. In earlier drafts, we tried to specify a few baseline codecs and formats that all browsers must support, but each of the possible formats caused some browser vendor to refuse to implement it.
HTML5 没有指定播放器必须支持哪些音频格式(渐进式或流媒体)。这由浏览器根据需求和实现可行性来确定。在早期的草案中,我们试图指定一些所有浏览器都必须支持的基线编解码器和格式,但每种可能的格式都导致一些浏览器供应商拒绝实施它。
The following appears to work in Safari (4.0.4, WebKit nightly 6531.21.10, r54538, Mac OS X 10.6.2), but not Chrome or Firefox:
以下似乎适用于 Safari(4.0.4,WebKit nightly 6531.21.10,r54538,Mac OS X 10.6.2),但不适用于 Chrome 或 Firefox:
<!DOCTYPE html>
<audio controls src="http://shoutcast.internet-radio.org.uk:10272/"></audio>
(note that <audio>
requires an end tag in the HTML serialization, it can't use an XML style self-closing tag, and I need to include controls
or autoplay
in order to actually start the audio)
(请注意,<audio>
在 HTML 序列化中需要一个结束标记,它不能使用 XML 样式的自关闭标记,我需要包含controls
或autoplay
以实际启动音频)
This is likely due to the fact that Safari gets support for Shoutcast "for free" because it just uses QuickTime to handle any audio and video URLs it is given, and QuickTime already has support for Shoutcast. This can also lead to some strange bugs, as QuickTime's HTTP implementation is, well, quirky, to put it kindly.
这可能是因为 Safari 获得了“免费”支持 Shoutcast,因为它只使用 QuickTime 来处理它提供的任何音频和视频 URL,而 QuickTime 已经支持 Shoutcast。这也可能导致一些奇怪的错误,因为 QuickTime 的 HTTP 实现是,好,古怪,好心地说。
I'd suggest filing bugs asking for Shoutcast support in browsers that don't support it. Here are the bug trackers for Firefox (Gecko/Mozilla), Chrome (Chromium), and Safari(if it happens not to work on Windows, or something like that).
我建议提交错误,要求在不支持 Shoutcast 的浏览器中支持 Shoutcast。以下是Firefox (Gecko/Mozilla)、Chrome (Chromium)和Safari的错误跟踪器(如果它碰巧不能在 Windows 上运行,或者类似的东西)。
回答by ninja
well I've checked ogg_vorbis stations. I downloaded some playlist and opened it in notepad, and copy out the url of a stream. So if you want to test it just copy this to empty file and name it something.html.
好吧,我已经检查了 ogg_vorbis 站。我下载了一些播放列表并在记事本中打开它,然后复制出流的 url。因此,如果您想测试它,只需将其复制到空文件并将其命名为 something.html。
<!DOCTYPE html>
<html>
<head>
<title>audio testing live stream!</title>
</head>
<body>
<audio controls="controls" autoplay="autoplay" src="http://oggvorbis.tb-stream.net:80/technobase.ogg">
</audio>
</body>
</html>
that's it!
就是这样!
BB
BB
回答by TechMonkey
<!DOCTYPE html>
<audio controls src="http://baldyradio.com:8010/;"></audio>
This works in the release version of IE9, Sad that the same can not be said for FireFox 4!
这适用于 IE9 的发布版本,可悲的是 FireFox 4 不能说同样的!
回答by Kurt Van den Branden
The above posts give the correct answer, allthough they don't mention the use of the slash. Make sure /;is there after the stream URL and port.
上面的帖子给出了正确的答案,尽管他们没有提到斜线的使用。确保/; 在流 URL 和端口之后是否存在。
<audio src="http://shoutcast.internet-radio.org.uk:10272/;" />
回答by Andrei
reading the HTML 5 audio specification (http://www.w3schools.com/html5/html5_audio.asp) W3C outlines which formats (MP3 or OGG) are supported by which browsers
阅读 HTML 5 音频规范 (http://www.w3schools.com/html5/html5_audio.asp) W3C 概述了哪些浏览器支持哪些格式(MP3 或 OGG)
What i would do is have an icecast server (not ShoutCast) streaming a MP3 and an OGG stream
我会做的是有一个 icecast 服务器(不是 ShoutCast)流式传输 MP3 和 OGG 流
using javascript detect the browser type - http://www.javascripter.net/faq/browsern.htm
使用 javascript 检测浏览器类型 - http://www.javascripter.net/faq/browsern.htm
if (the browser does not support HTML5){ print a message - USE a New Browser }
如果(浏览器不支持 HTML5){ 打印消息 - 使用新浏览器 }
if (the browser supports HTML5 and OGG streaming (use list from W3c)){ use the OGG stream from the icecast server in the SRC tag }
if(浏览器支持 HTML5 和 OGG 流(使用来自 W3c 的列表)){ 在 SRC 标签中使用来自 icecast 服务器的 OGG 流 }
if (the browser supports HTML5 MP3 streaming (use list from W3C)){ use the MP3 stream from the icecast server in the SRC tag }
if(浏览器支持 HTML5 MP3 流(使用来自 W3C 的列表)){ 在 SRC 标签中使用来自 icecast 服务器的 MP3 流 }
i think this would cover all the major browsers and would solve most peoples problems you will probably find in the future this will be redundant as more browsers support
我认为这将涵盖所有主要浏览器,并将解决大多数人的问题,您将来可能会发现这将是多余的,因为更多浏览器支持
回答by 000
<audio controls src="http://example.com:8000/mountpath;"></audio>
回答by Kelly Clowers
Well, Firefox and Opera do not support non-Free codecs such as mp3 (as with the Opera 10.5 alpha, FF 3.5 and later supports only PCM wav and Ogg Vorbis for audio). I believe Chrome and Safari do support MP3, however.
好吧,Firefox 和 Opera 不支持非自由编解码器,例如 mp3(与 Opera 10.5 alpha 一样,FF 3.5 及更高版本仅支持 PCM wav 和 Ogg Vorbis 音频)。不过,我相信 Chrome 和 Safari 确实支持 MP3。
The next problem is that your URL appears to point to a webpage describing the stream, not to a stream.
下一个问题是您的 URL 似乎指向描述流的网页,而不是流。
Finally, as far as I know, no one has implemented a playlist parser for the audio element (the spec only mentions audio files, not playlists), which is a problem here, as even when you click "listen" you get a playlist rather than a raw stream.
最后,据我所知,没有人为音频元素实现播放列表解析器(规范只提到音频文件,而不是播放列表),这是一个问题,因为即使当你点击“听”你得到一个播放列表而不是比原始流。
回答by Hector Lara
Yes you can play ShoutCast2 I use it like this in this way
是的,你可以玩 ShoutCast2 我就是这样用的
<audio preload="none" autoplay="autoplay" controls="controls">
<source src="http://178.32.62.172:9079/stream" type="audio/mpeg">
Your browser does not support this player, please update the version
</audio>