jeudi 1 janvier 2015

Getting onclick audio on website working on mobile devices

I'm struggling to get audio on mobile devices working and was wondering if any of you could help. I'm using mp3 as the format and it works as far as I know on desktop.



<script language="javascript" type="text/javascript">
function playRandomSound(){
var sounds = [
"http://ift.tt/1xjXUwm",
"http://ift.tt/1vM92ho"];

var soundFile = sounds[Math.floor(Math.random()*sounds.length)];
document.getElementById("player").innerHTML="<embed src=\""+soundFile+"\" hidden=\"true\" autostart=\"true\" loop=\"false\" />";


}
</script>


<a href="#" onclick='playRandomSound();'>Play</a>
<span id='player'></span>




Aucun commentaire:

Enregistrer un commentaire