用PHP知道浏览器是否可以播放带有html5音频标签的音频文件

问题描述:

我的问题可能很奇怪,但我不知道该如何表达……

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.