HTML 5 AudioElement不会在IOS 11设备上的Safari中播放mp3 Livestream [英] HTML 5 AudioElement won't play mp3 Livestreams in safari on IOS 11 devices

查看:470
本文介绍了HTML 5 AudioElement不会在IOS 11设备上的Safari中播放mp3 Livestream的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是无线电广播公司的网络开发人员。自IOS 11发布以来,我们收到了一些用户投诉,称我们的音频直播流不再在IOS 11设备上播放。要在我们的网站中嵌入流,我们使用HTML5 AudioElement。在iPhone IOS 11上调试javascript时,我们发现调用音频元素play()方法会导致ErrorError 4的MediaError(MEDIA_ERR_SRC_NOT_SUPPORTED)。所有其他设备(Android,Windows和IOS 10及以下)播放流没有任何问题。
我创建了一个小代码示例

I'm a web developer at a radio broadcaster. Since the release of IOS 11, we received several user complaints that our audio live streams can't be played on IOS 11 devices anymore. To embed the streams in our websites we use the HTML5 AudioElement. When debugging the javascript on an iPhone whit IOS 11 we recognized that calling the audio elements play() method resulted in a MediaError of ErrorCode 4 (MEDIA_ERR_SRC_NOT_SUPPORTED). All other devices (Android, Windows and IOS 10 and below) play the streams without any problem. I created a little codepen example

    <audio controls>
      <source src="http://hr-hrinfo-
      live.cast.addradio.de/hr/hrinfo/live/mp3/128/stream.mp3" 
      type="audio/mpeg;codecs="mp3"">
      Your browser does not support the audio element.
    </audio>

https://codepen.io/ampersand83/pen/pWwgKm 我只是通过AudioTag创建一个AudioElement,并将源标记传递给我们的一个流URL。

https://codepen.io/ampersand83/pen/pWwgKm in which I just create an AudioElement via the AudioTag and hand the source Tag one of our stream URLs.

运行IOS 10及以下版本的设备播放流没有任何问题,以及当前的Android或Windows设备。但是,运行IOS 11.0.1的设备无法播放流。我找不到任何关于为什么这不再可能的信息。有没有人知道为什么我们的流不再工作,可以给我们建议我们可以做些什么让他们再次工作?

Devices running IOS 10 and below play the streams without any problem as well as current android or windows devices. However, a device running IOS 11.0.1 can't play the stream. I can't find any information on why this wouldn't be possible anymore. Does anybody have an idea why our streams won't work anymore and can give us advice on what we can do to make them work again?

推荐答案

我在尝试将带有音频控件的本地HTML文件加载到UIWebView时看到了同样的问题。但是,我的文件是.m4a音频文件。我发现只需删除类型即可。所以我的HTML看起来像这样:

I saw this same issue when trying to load a local HTML file with audio controls into a UIWebView. However, my file was an .m4a audio file. I found that just removing type did the trick. So my HTML looked like this:

<div class="audio"><audio controls><source src="my_local_audio_file.m4a"></audio></div>

使用 type = audio / mp4 也有效为了我。所以我猜它是一个不兼容的mime类型,只是删除类型将是最好的选择。

Using type=audio/mp4 also worked for me. So I'm guessing it's an incompatible mime type and just removing the type would be the best option.

希望这有帮助。

这篇关于HTML 5 AudioElement不会在IOS 11设备上的Safari中播放mp3 Livestream的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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