html5 live,html5 audio livestreaming

问题

I'm creating my own audio, without controls of the browser.

I have these functions, called when clicked some buttons:

function play()

{

audio.play();

}

function play()

{

audio.pause

}

function stop()

{

audio.pause();

audio.src = audio.src;

}

But for now, I only can reproduce mp3 or ogg files, but not a live stream radio.

I read about some plugins, but I need do it with pure html5.

Could you help me, please?

Thanks very much,

回答1:

Unfortunately, there is still no single video and audio codec, which is supported by all browsers! The programmers have to ensure that there is fallback provided for use-cases where browser A doesn't support codec B and vice versa.

You can take a look at this compatibility table, for both desktop and mobile browsers.

Desktop:

Internet Explorer (9.0+) support MP3 and AAC codecs

Chrome (6.0+) support Ogg Vorbis, MP3, WAV+

Firefox (3.6+) support Ogg Vorbis, WAV

Safari (5.0+) support MP3, AAC, WAV

Opera (10.0+) support Ogg Vorbis, WAV

Mobile:

Opera Mobile (11.0+) supported codecs are device-dependent

Android (2.3+) supported codecs are device-dependent

Mobile Safari (iDevices with iOS 3.0+) support MP3, AAC

Blackberry (6.0+) support MP3, AAC

Since flash is still widespread enough, it's probably the safest fallback.

Also, I want to note that there's nothing worse to use some library, some of them (e.g. jPlayer) provides very powerful interface and this only can help you to produce better code!

I think you can find everything you want to know in the following article: HTML5 Audio Radio Player by Opera Devs

回答2:

Playing audio from a "live source" seems to be supported by modern browsers. Basically just use the normal HTML 5 audio tags, and input the "live stream" URL as the source, ex:

And the stream "just works" as it were, though attempting to seek with the default controls does nothing. So eventually you may want to replace the controls with "custom" ones, in normal HTML 5 media style. For backward compatibility to non HTML 5 browsers, this project may be useful: https://github.com/etianen/html5media/wiki/Embedding-audio (haven't tested it with live streaming but could/should work). Mp3 codec seems to be supported in major browsers (barring possibly firefox on Linux [?]). Opus might be another nicely cross platform option, I'm not sure codec wise what is the "best" choice as it were.

With some streams (shoutcast I presume) I have had to add a closing ';' to the URL, see https://stackoverflow.com/a/3182814/32453 for notes there, but that's basically just to get the "right" url.

来源:https://stackoverflow.com/questions/16978301/html5-audio-livestreaming

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值