I have a bit of code to play audio tag HTML5 when clicked. Works properly in all browsers. I recently tried to convert it to automatically play when the page opens (no click required). Works fine in Chrome and FF, but won't play in IE... although I don't see an obvious error.
// add a 'self play' function on a wrapper div jQuery('.autoplay').each( function(i) { if( jQuery(this).attr("rel") ) { var xv = jQuery(this); x = jQuery(this).attr('rel') + ext; audioElements.push( document.createElement('audio') ); //alert(audioElements.length); //alert(xv); // alert(x); y = audioElements.length-1; audioElements[y].setAttribute('src', x); audioElements[y].load(); audioElements[y].addEventListener("canplay", function(){ xv.addClass('canplay'); }); // audioElements[y].currentTime=0; audioElements[y].play(); // alert(x); return true; } });
The live site is http://jchmusic.com. But again, if you go to http://jchmusic.com/songs-from-detroit and click on any icon, the same basic code works fine.
Any ideas?
Source: http://stackoverflow.com/questions/13318874/html5-audio-auto-play-ie-doesnt-play
christine christine will ferrell double fine adventure turbo tax katharine mcphee cold mountain
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন