如何在IE(9+)和Safari(Pad)中使用HTML5音频播放.m4a? [英] How to play .m4a with HTML5 audio in IE(9+) and Safari (Pad)?

查看:890
本文介绍了如何在IE(9+)和Safari(Pad)中使用HTML5音频播放.m4a?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在IE(9+)和Safari(iPad,iPhone)上播放.m4a文件(在iPhone上录制)。我面临设置正确的MIME类型的问题。对于在IE10中播放,我需要设置 audio / mp4 ,但对于Safari audio / aac

使用 audio / mp4 我在iPad上收到无法播放音频文件
使用 audio / aac 我得到错误:不支持的音频类型或无效的文件路径

是否可以为这两种类型设置?

 < audio controls =controlsautoplay =autoplay> 
< source src =play.aspx?filename = sound.m4atype =audio / mp4/>
< / audio>



不是我的解决方案。



我通过.aspx页面提供文件,所以我可以控制HTTP头。



观察页面 HTML 5音频在所有浏览器中使用m4a,oga,mp3和Flash ,似乎可能的解决方案是给 type =audio / mp4和没有conten类型头。但是,在aspx中删除HTTP头是太复杂的问题,我想解决(见删除/隐藏/禁用Azure / IIS7中没有UrlScan的过多HTTP响应头)。

解决方案

音频仍在工作草稿中,因此浏览器体验会有所不同。



话虽如此,最流行的mime类型是 audio / x-m4a 。有些网站显示 audio / m4a-latm 作为 m4a 音频的有效MIME类型,



您可以在不同的浏览器中试试这个程式码片段,看看是否有效 - 我在IE11,Chrome(v37)和IE9通过Dev Tools进行模拟)。



音频标签示例



我还发现(个人观察)记录在iPhone上的音频在网络上不能播放大部分时间。几乎所有的浏览器说,该文件是无效的,如果你下载录制的文件,它甚至不能播放在媒体播放器(例如Windows Media Player)。我怀疑iOS核心音频是在这里责怪,但还没有发现任何结论性的。



此时,使用Flash备用广告素材似乎是最佳选项(在iHateFlash 设备)。


I need to play .m4a files (recorded on iPhone) in IE(9+) and Safari (iPad, iPhone). I am facing problem with setting correct MIME Type. For playing in IE10 I need to set audio/mp4 but for Safari audio/aac.
With audio/mp4 I am getting Cannot play audio file on iPad. With audio/aac I am getting Error: Unsupported audio type or invalid file path in IE

Is there a type I can set for both?

<audio controls="controls" autoplay="autoplay">
   <source src="play.aspx?filename=sound.m4a" type="audio/mp4" />
</audio>

Notes

Using an alternative player is not a solution for me.

I serve the files thorough .aspx page so I can control HTTP headers.

From observing the page HTML 5 Audio Across All Browsers using m4a, oga, mp3 and Flash it seems that possible solution is to give type="audio/mp4" and NO conten-type header. However removing HTTP header in aspx is rather too complex for problem I am trying to solve(see Removing/Hiding/Disabling excessive HTTP response headers in Azure/IIS7 without UrlScan).

解决方案

Audio is still in working draft, so browser experience will vary.

Having said that, the mime type that's most prevalent is audio/x-m4a. Some sites show audio/m4a-latm as a valid mime type for m4a audio but as of this writing, even Chrome doesn't recognize that mime type.

You can try this snippet in different browsers to see if it works - I verified it in IE11, Chrome (v37) and IE9 (emulated via Dev Tools).

Audio Tag sample

I've also found (personal observation) that audio recorded on iPhone doesn't play most of the time on web. Almost all browsers say the file is invalid and if you download the recorded file, it doesn't even play in media players (e.g Windows Media Player). I suspect iOS core audio is to blame here but haven't found anything conclusive yet. Audio recorded from Android works fine though.

At this point, having a flash fallback seems like the best option (won't help on iHateFlash devices though).

这篇关于如何在IE(9+)和Safari(Pad)中使用HTML5音频播放.m4a?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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