html5 - How to play a wav audio file with jQuery? Why can't the wav file be decoded? -
i'm trying wav file play when submit button pressed. reason keep seeing error:
media resource file:///users/bryan/webapp/buzzer.wav not decoded.
what doing wrong?
<!doctype html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.css" /> <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script> <script src="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.js"></script> </head> <body> <audio id="buzzer" src="buzzer.wav" type="audio/wav">your browser not support <audio> element.</audio> <form id='sample' action="#" data-ajax="false"> <fieldset> <input value="start" type="submit"> </fieldset> </form> <script type="text/javascript"> var buzzer = $('buzzer')[0]; $(document).on('submit', '#sample', function() { alert("submitted"); buzzer.play(); return false; }); </script> </body> </html>
it sounds problem lies wav file, , possibly specific browser in.
see related post: firefox won't play .wav files using html5 <audio> tag?
Comments
Post a Comment