0

ボタンを押したときに音を鳴らそうとしています。JavaScriptファイルでこの関数を使用しました

function playSound(soundfile) {
    alert('hello');
     document.getElementById("sound").innerHTML=
     "<embed src=\""+soundfile+"\" hidden=\"true\" autostart=\"true\" loop=\"false\" />";
     }

alert('hello')を実行しますが、残りは実行しません。エラーも発生しません。それは単に再生されません。

ここで関数を呼び出します

<button class="button_start" style="float:left;color:green;" onclick="start();">Start</button>

start() 関数はここにあり、playSound() が含まれています。

function start(){

    playSound('bip.mp3');

    if (control == -1) alert('Please select the time and press "Set" before starting a countdown');
    else if (control == 0) { control = 1; timer(); }
    //else if (control == 1) alert('Your countdown is already running');    
}

はい、HTML にこれがあります。

<div id="sound"></div>

Chrome と Firefox の両方を試しましたが、どれも機能しません。

ページ全体がタイマーで、最後にビープ音が鳴るはずだったので、本当に必死です。

ありがとう!

4

0 に答える 0