i want able play sound on html page using javascript when event happens.
basically want data server using ajax , if specific, play sound. works great on pc browsers, have issues making work on safari (ios) , chrome (android). read play sound on chrome (i guess safari also), needs triggered user event (gesture, click, etc.). here simplified code:
<!doctype html> <head> <meta http-equiv="refresh" content="7" /> </head> <body> <button onclick="playsound()" id="button">click me</button> <script> window.setinterval(function(){ parent.document.getelementbyid('button').click(); }, 5000); function playsound() { var audio = new audio('http://www.soundjay.com/button/beep-01a.wav'); audio.play(); } </script> </body> </html> i thought workaround work (trigger click event using js), still no sound. 1 additional thing want ajax code every few seconds , when phone blocked. found solution (and applied changes previous try):
background.html:
<!doctype html> <head> <meta http-equiv="refresh" content="3" /> </head> <body> <script> parent.run_function_from_core_page(); </script> </body> </html> in index.html:
<iframe src="background.html" style="display:none;"></iframe> but again, works great on pc, no sound on either chrome mobile , safari mobile. suggestions? possible?
Comments
Post a Comment