javascript - Audio on Chrome for mobile isn't working using Jquery -


i tried play sound (wav, ogg) using html5 javascript on chrome mobile, it's not working. tried "fake" click, nothing happened.

$(document).on("click", "#audio", function(){     var = $('#audio');     if(a.length !== 0){         a.get(0).play();     } }); $('#audio').click(); 

or

var audio = new audio("file.ogg"); audio.play(); 

html

<audio controls="controls" id="audio" class="hidden">    <source src="file.wav"></source> </audio> 

thank you.

i'd try this:

$('some-button').on('click', function(){     $('audio')[0].play(); }); 

in other words - use button receive click , find audio element , make start playing.

there small, specialized example here:

http://jsbin.com/arecoq/84

note music licensed under creative commons by-cc-sa, see further info here.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -