Reputation: 31
I am a complete novice with HTML5 and coding for that matter. I have been trying to get to grips with the web audio API. I want a sound to play at a click of a button. I used a tutorial posted on HTML5Rocks, but cannot get it to work. I have tried to use jfiddle to help me troubleshoot, but to no avail.
here is my code: http://jsfiddle.net/ue8WP/
Upvotes: 3
Views: 1464
Reputation: 97
Try this:
function playsound()
{
var filepath='sounds/'+....+'.mp3'; //example
var audio = new Audio();
audio.src = filepath;
audio.controls = true;
audio.autoplay = true;
}
Upvotes: 1
Reputation: 118
Here's a simplified version of your code that should work fine. You only need to load some other sample sound, since there is a problem with fetching the one you provided (not allowed by Access-Control-Allow-Origin).
Upvotes: 0