Knowing with PHP if the browser can play audio file with html5 audio tag

99封情书 提交于 2020-01-15 09:14:07

问题


My question might be weird, but I don't know how to phrase it…

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.

How could I proceed ?

Thanks !


回答1:


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.




回答2:


Modernizr will do the deal in the end. http://modernizr.com/docs/#features-html5 Thank you !



来源:https://stackoverflow.com/questions/18678400/knowing-with-php-if-the-browser-can-play-audio-file-with-html5-audio-tag

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!