如何使用 HTML5 播放shoutcast/icecast 流? [英] How could I play a shoutcast/icecast stream using HTML5?

查看:34
本文介绍了如何使用 HTML5 播放shoutcast/icecast 流?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用 HTML5 播放喊叫/冰播流?

Is it possible to play a shoutcast/icecast stream using HTML5?

如果是这样,我应该如何实施?

If so, how should I implement it?

推荐答案

2020 更新

现代浏览器不需要任何特殊处理或服务器端解决方法来播放音频.只需使用直接链接到一个或多个流源(不是播放列表)的音频标签:

2020 update

Modern browsers don't need any special treatment or server-side workarounds to play audio. Simply use an audio tag with a direct link to one or more stream sources (not a playlist):

<audio>
    <source src="http://relay.publicdomainradio.org/classical.mp3" type="audio/mpeg">
</audio>

来自 MDN:

HTML 元素 用于在文档中嵌入声音内容.它可能包含一个或多个音频源,使用 src 属性或 元素表示:浏览器将选择最合适的一个.

The HTML <audio> element is used to embed sound content in documents. It may contain one or more audio sources, represented using the src attribute or the <source> element: the browser will choose the most suitable one.

浏览器支持 flacmp3vorbisaacopuswav.有关 caniuse.com 的更多详细信息.

Browsers support flac, mp3, vorbis, aac, opus and wav. More details on caniuse.com.

在http请求的末尾添加一个分号.这是shoutcast 提出的协议,用于覆盖其浏览器检测.像这样:

Add a semicolon to the end of the http request. It IS the protocol set forth by shoutcast to override it's browser detection. Like this:

<audio controls src="http://shoutcast.internet-radio.org.uk:10272/;"></audio>

这篇关于如何使用 HTML5 播放shoutcast/icecast 流?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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