javascript - No audio playback on mobile device -


here link http://breakingbadbutton.com/

basically hit button , plays audio file. can't figure out why doesn't work on iphone/ipads...

the script:

<script type="text/javascript">    $(document).ready(function() {   var sounds = [             "audio/basement.mp3",              "audio/half.mp3",              "audio/science.mp3",              "audio/tone.mp3",              "audio/minerals.mp3",              "audio/sticks.mp3",              "audio/gatorade.mp3",              "audio/roll.mp3",              "audio/right.mp3",              "audio/knocks.mp3",              "audio/hotdogs.mp3",              "audio/keys.mp3",              "audio/heil.mp3",              "audio/money.mp3",              "audio/ours.mp3",              "audio/pass.mp3"],    picksound = 0;  $("button").click(function() {    $('#sounddiv').html("<embed src=\""+ sounds[picksound] +"\" hidden=\"true\" autostart=\"true\" />");    picksound = (picksound + 1) % sounds.length; }); 

});

you should use bit more upto date, believe <embed> has deprecated in html4.01

instead, use <audio> tag sort of thing.. example here

you can add attributes autoplay etc, they're available here

here's fiddle of player changing mp3, although mp3's arent available wont play here :-) http://jsfiddle.net/mp3zm/


Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -