<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>用JavaScript检测音频格式支持</title>
    <script type="text/javascript">
        function checkAudio() {
            var myAudio = document.createElement('audio');
            if (myAudio.canPlayType) {
                if ("" != myAudio.canPlayType('audio/mpeg')) {
                    document.write("您的浏览器支持mp3编码。<br>");
                }
                if ("" != myAudio.canPlayType('audio/ogg; codecs="vorbis"')) {
                    document.write("您的浏览器支持oog编码。<br>");
                }
                if ("" != myAudio.canPlayType('audio/mp4; codecs="mp4a.40.5"')) {
                    document.write("您的浏览器支持aac编码。");
                }
            }
            else {
                document.write("您的浏览器不支持要检测的音频格式。");
            }
        }
        window.onload = function () {
            checkAudio();
        }
    </script>
</head>
<body>
</body>
</html>

 

相关文章:

  • 2021-07-06
  • 2021-04-21
  • 2021-08-26
  • 2021-09-01
  • 2022-12-23
  • 2021-09-17
猜你喜欢
  • 2022-12-23
  • 2021-05-09
  • 2022-12-23
  • 2022-12-23
  • 2021-12-17
  • 2021-12-06
  • 2021-12-05
相关资源
相似解决方案