用PHP知道浏览器是否可以播放带有html5音频标签的音频文件 [英] Knowing with PHP if the browser can play audio file with html5 audio tag
问题描述
我的问题可能很奇怪,但我不知道该如何表达……
My question might be weird, but I don't know how to phrase it…
实际上,我想知道用户的浏览器是否支持mp3,ogg和wav文件(我需要每个文件的信息). 我知道,我可以一开始就将Firefox和safari/chrome区别开来,但是有几种浏览器我不会考虑.
Actually, I would like to know whether or not the user's browser support mp3, ogg and wav files (I want the information for each). I know, I could just make the distinction between firefox and safari/chrome for a start, but there are several browsers I wouldn't take into consideraton.
我该如何进行?
谢谢!
推荐答案
可靠检测HTML5音频(以及随后对编解码器的支持)的唯一方法是在客户端进行.使用PHP(或任何服务器端)的唯一可用功能是进行用户代理嗅探,这是众所周知的,不可靠.
The only way to reliably detect HTML5 audio (and subsequently codec support) is to do so client-side. The only capability available to you with PHP (or anything server-side) is to do user-agent sniffing, which is notoriously unreliable.
这篇关于用PHP知道浏览器是否可以播放带有html5音频标签的音频文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!