残念ながら、私は html に完全に慣れていないので、質問に答えていただければ幸いです。
Web ページに 3 つのオーディオ ファイルを実装しようとしていますが、ソース ファイルの 1 つしか再生されません。他のファイルのボタンは機能しますが、1 つのソースからしか再生されません。手伝って頂けますか?
コードは次のとおりです。
<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-->
どうもありがとう!