简体   繁体   中英

.wav audio files will not play - Javascript

I am having trouble playing a .wav file. This is my code for fetching the file:

var tableHitSound = new Audio("707 Rim.wav");

And for playing it:

tableHitSound.load();
tableHitsound.play();

There are no errors in this code, and it finds the file fine, however it does not play the file ie I dont hear anything.

console.log(tableHitSound.duration); Returns NaN

console.log(tableHiSound.ended); Returns false

Is there anything I am doing wrong?

Two possible solutions:

  • tableHitsound.play(); -- 's' in 'sound' is lower case here but as upper case in variable initialization

  • Make sure it is 16bit wav format

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