如何在Android上玩实况AAC流与HTML5音频元素 [英] How to play live AAC stream on Android with html5 audio element

查看:136
本文介绍了如何在Android上玩实况AAC流与HTML5音频元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图嵌入HTML5音频标签在一个页面,让玩实况AAC +流来自icecast服务来了。

I am trying to embed an html5 audio tag in a page to allow playing a live AAC+ stream coming from an Icecast server.

据href=\"http://developer.android.com/guide/appendix/media-formats.html\" rel=\"nofollow\">媒体格式的开发者指南的

According to the media formats developer's guide, Android supports playback for several AAC flavors, either inside an MPEG-4 container or in ADTS.

我已经成功地扮演了AAC-CN codeD音频文件在MPEG-4容器,这样的:

I have successfully played AAC-encoded audio files in an MPEG-4 container, thus:

<audio controls="controls">
  <source src="http://www.example.com/audio/program1.mp4" type="audio/mp4"/>
</audio>

不过,我一直无法与音频标签播放任何AAC实况流(当中,据我了解,是利用ADTS的Icecast输出)。我曾尝试设置不同类型(例如,音频/ AAC,该玩家说,它可以通过可能播放)以及不同的文件流URL扩展。没有什么作品。该播放器,顺便说一下,初始化,如果一切正常,那么当你preSS播放按钮没有任何反应(除播放键更改为暂停图标除外)。

However, I have not been able to play any AAC live stream (which, as far as I understand, is output by Icecast using ADTS) with the audio tag. I have tried setting different types (e.g., "audio/aac", which the player says it can "probably" play) as well as different file extensions for the stream URL. Nothing works. The player, by the way, initializes as if everything is OK, then when you press the play button nothing happens (other than the play button changing to a pause icon).

我一直能玩实况AAC流的唯一方法是通过使用指向包含的链接流的RTSP版本.sdp清单的URL。然后在浏览器的手离开流本地音频播放器或其他音频应用程序,其中一个短暂的缓冲期后播放。这不是我们的选择,因为我们想用一个简单的Icecast服务器为我们流。

The only way I have been able to play a live AAC stream is by using a URL pointing to a .sdp manifest containing a link to an RTSP version of the stream. The browser then hands off the stream to the native audio player or another audio app, which plays it after a brief buffering period. This is not an option for us, as we would like to use a simple Icecast server for our stream.

有只是没有办法通过HTTP打在Android现场AAC音频流?这似乎iOS的支持,但不是Android系统。

Is there just no way to play a live AAC stream on Android via HTTP? It seems iOS supports it, but not Android.

推荐答案

从缺乏相反的反应,我不得不得出结论,答案原来的问题是,不,这是不可能的使用HTML5音频标签从icecast服务。

From the lack of responses to the contrary, I have to conclude that the answer to the original question is, "No, it is not possible to use the HTML5 audio tag to play a live AAC+ stream from an Icecast server".

我张贴的答案,分享我终于实现了。

I am posting an answer to share what I ended up doing.

我的第一个倾向是简单地使用MP3代替AAC的成立第二的Icecast流。这会工作,但你必须愿意接受Android的音频播放器,MP3流引入缓冲延迟。不幸的是,在64 KPBS的Andr​​oid让你等待40秒钟,然后就会开始播放MP3流。诚然,64 KPBS不太好品质的MP3,但即使在128 kbps的缓冲接管20秒,足以让听众得出结论,流了下来。所以MP3是不是我们的选择。

My first inclination was simply to set up a second Icecast stream using MP3 instead of AAC. This will work, but you must be willing to accept the buffering delay that Android's audio player introduces with MP3 streams. Unfortunately, at 64 kpbs Android makes you wait for over 40 seconds before it will start playing the MP3 stream. Admittedly, 64 kpbs is not very good quality for MP3, but even at 128 kbps the buffering takes over 20 seconds, enough for listeners to conclude that the stream is down. So MP3 is not an option for us.

我最终的解决办法是要求我们的CDN添加Wowza应用程序,从AAC +流的Icecast拉,并使用HLS transmuxes它。

My eventual solution was to ask our CDN to add a Wowza application that pulls from the AAC+ Icecast stream and transmuxes it using HLS.

现在我的音乐标签是这样的:

Now my audio tag looks like this:

<audio controls="controls">
  <source src="http://www.example.com/wowza/stream.m3u8"/>
  <source src="http://www.example.com/audio/aac"/>
</audio>

请注意,我必须首先列出HLS源,因为否则的Andr​​oid设备将实际挑选的Icecast流,并尽量发挥它,它不能(你会觉得它会知道够不这样做)

Note that I had to list the HLS source first, because otherwise the Android device will actually pick the Icecast stream and try to play it, which it can't (you'd think it would know enough not to do that).

所以,最后,因为它是通过从HLS的Icecast交付,而不是直接的Andr​​oid确实起到了直播AAC +流无延迟,只要。我必须说,我感到非常失望与Android,无论是它的缺乏直接的Icecast AAC +,并为其办理穷人生活MP3流的支持,尤其是在竞争(IOS)处理你扔在它的一切都不眨。

So in the end Android does play a live AAC+ stream with no delay, as long as it is delivered via HLS, and not directly from Icecast. I must say I was very disappointed with Android, both it's lack of support for direct Icecast AAC+ and for its poor handling of live MP3 streams, especially since the competition (iOS) handles everything you throw at it without blinking.

这篇关于如何在Android上玩实况AAC流与HTML5音频元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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