Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
110 views
in Technique[技术] by (71.8m points)

How to put a if this happens, then play this sound in HTML

How can I put an if answered correctly play sound: "mp3 url" in HTML?

I tried multiple ways, but they still don't work.

I am trying to do it with Tampermonkey

question from:https://stackoverflow.com/questions/65927402/how-to-put-a-if-this-happens-then-play-this-sound-in-html

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You'll need Javascript to check if your condition returns true.

if(answeredcorrectly) {
    let mp3= new Audio('urltomp3file.mp3);
    mp3.play();
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...