0

我一辈子都无法让音频标签在 IE9 中工作。这是我的代码,我到底做错了什么?我确保我的标签都井井有条,并且我设置了一个例外来强制 IE9 使用 HTML5。在此先感谢您的帮助。

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>CD Cover Animation</title>

    <script type="text/javascript" src="js/animCD.js?rev=new"></script>    
    <link rel="stylesheet" href="style.css" type="text/css" />

    <!-- Show Audio when button is clicked -->

    <script type="text/javascript">
        function showAudio()
        {
            document.getElementById('audioInterview').style.visibility='visible';
        }
    </script>

    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

    </head>
    <body>

    <video autoplay="autoplay" id="videoBackground" width="1280" height="720" preload="auto" ontimeupdate="animCD_onprogress();">
        <source id="colorVid_mp4" type="video/mp4" src="img/luther-2.mp4">
        <source id="colorVid_ogg" type="video/ogg" src="img/luther-2.ogg">
    </video>


        <audio id="audioInterview" preload='auto' controls style="visibility:hidden"
            <source src="audio/interview.mp3" type="audio/mp3">
        Your browser does not support the audio element.
        </audio>


    <!-- <div class="buttonSkip" onclick="alert('Clicked Skip');"></div> -->



    <p><a class="ex2" href="http://www.lrltv.org/muslims-nuclear.html">[ skip intro]</a></p>

    <div id="buttonPlacement" class="buttonPlacement">
        <div onclick="showAudio();" class="btnDonate"></div>
        <div onclick="alert('Clicked Buy');" class="btnBuy"></div>
    </div>
            <!-- Add more buttons here -->

    </body>
</html>
4

1 回答 1

0

正如评论所说,您需要关闭音频标签。但他们并不意味着,</audio>而是>在行尾。它应该如下所示:

<audio id="audioInterview" preload="auto" controls="controls" style="visibility:hidden">
        <source src="audio/interview.mp3" type="audio/mp3">
        Your browser does not support the audio element.
</audio>

我也使用控件=“控件”。

如果您不需要显示音频控件,您也可以在纯 JavaScript 中执行此操作。

var audioInterview = new Audio('audio/interview.mp3');
audioInterview.play();

然后删除 HTML 音频标签。

于 2012-12-05T21:36:44.860 回答