简体   繁体   中英

How to play an external audio file with javascript not Jquery?

有谁知道如何用JavaScript播放声音,例如我想播放声音sounds/main.mp3

Start by defining your audio file.

Then you can call it where you want in your scripts with play().

var myAudio = new Audio('sounds/main.mp3');
myAudio.play();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM