很遗憾,我对 html 完全是个菜鸟,所以我希望你能回答我的问题。
我正在尝试在我的网页上实现三个音频文件,但只有一个源文件正在播放。其他文件的按钮有效,但它们只能从一个来源播放。你能帮助我吗?
这是代码:
<div class="sound1">
        <div style="text-align:center; width:100px; height:100px; margin-left:390px; margin-top:0px; background-repeat:no-repeat; "> 
            <button style="background-image:url(speaker_bakur.png); width:100px; height:100px; border:transparent;
                ; "margin-top:0px; margin-left:0px;" onclick="playPause();" ></button> 
                <audio id="Sound">
                <source src="" type="audio/wav" />
                <source src="" type="audio/ogg" />
                <source src="svartbakur-4.mp3" type="audio/mpeg" />
                </audio> 
                </div>
                <script type="text/javascript"> 
                var myAudio=document.getElementById("Sound"); 
                function playPause()
                { 
                if (myAudio.paused) 
                myAudio.play(); 
                else 
                myAudio.pause(); 
                }
                </script>
                </div>
                </div><!--Div hyphenate-->
<div class="sound2">
                <div style="text-align:center; width:100px; height:100px; margin-left:390px; margin-top:0px; background-repeat:no-repeat; "> 
                <button style="background-image:url(speaker_likka.png); width:100px; height:100px; border:transparent;
                ; "margin-top:0px; margin-left:0px;" onclick="playPause();" ></button> 
            <audio id="Sound">
                <source src="" type="audio/wav" />
                <source src="" type="audio/ogg" />
                <source src="likka-6.mp3" type="audio/mpeg" />
            </audio> 
        </div>
        <script type="text/javascript"> 
            var myAudio=document.getElementById("Sound"); 
            function playPause()
            { 
                if (myAudio.paused) 
                myAudio.play(); 
                else 
                myAudio.pause(); 
            }
            </script>
    </div>
    </div><!--Div hyphenate-->
<div class="sound3">
        <div style="text-align:center; width:100px; height:100px; margin-left:390px; margin-top:0px; background-repeat:no-repeat; "> 
            <button style="background-image:url(speaker_fiskimasi.png); width:100px; height:100px; border:transparent;
                ; "margin-top:0px; margin-left:0px;" onclick="playPause();" ></button> 
                <audio id="Sound">
                <source src="" type="audio/wav" />
                <source src="" type="audio/ogg" />
                <source src="fiskimasi-21.mp3" type="audio/mpeg" />
                </audio> 
                </div>
                <script type="text/javascript"> 
                var myAudio=document.getElementById("Sound"); 
                function playPause()
                { 
                if (myAudio.paused) 
                myAudio.play(); 
                else 
                myAudio.pause(); 
                }
                </script>
                </div>
                </div><!--Div hyphenate-->
非常感谢!