this question has answer here:
- playing audio javascript? 10 answers
- play sound javascript 3 answers
for javascript:
is possible browser play sort of sound/music when image appears? perhaps play mp3 file in music library? right now, best can is:
if (document.getelementbyid("happyface")) { window.alert("attention: happy face detected."); } i should mention have page refreshing itself, loop isn't necessary (at least, don't think so).
just use audio tag that:
function sound(){ var audio = document.createelement("audio"); audio.src = "your_path_to_soundfile.wav"; audio.addeventlistener("ended", function () { document.removechild(this); }, false); audio.play(); } if (document.getelementbyid("happyface")) { sound(); }
Comments
Post a Comment