I have a .wav that I want to play when a person clicks on a link. How do I go about doing that? I'm not exactly an expert at html or css or javascript so be gentle with me
Asked
Active
Viewed 200 times
1 Answers
0
Reference
Playing audio with Javascript?
Example
Two Links
<a href='#' class="playButton">Play</a>
<a href='#' class="stopButton">Stop</a>
jQuery click Events
$(document).ready(function(){
var audio;
$("a.playButton").click(function(){
console.log("playing");
audio = new Audio('http://download.wavetlan.com/SVV/Media/HTTP/WAV/Media- Convert/Media-Convert_test1_Alaw_Mono_VBR_8SS_16000Hz.wav');
audio.play();
});
$("a.stopButton").click(function(){
console.log("Pause");
audio.pause();
});
});
Now this probably isn't the most accurate way to do this but it gives you an idea of how this works. If you want to use the built in audio
tag you can do that too cause that will give you the controls and other helpful things.
JSFIDDLE

ruthless
- 309
- 3
- 13