On my website I have an embedded audio that automatically starts and runs in the background (I have the audio embedded, because a normal can't be autoplayed in chrome). Now I am trying to find a way to make that audio start at a random point in the clip.
<body onload="audiofunction()">
<embed id="audio" src="berlin.mp3" type="audio/mpeg" autostart="true" loop="true">
<script>
function audiofunction(){
var audio = document.getElementById("audio");
alert(audio);
var max = audio.duration + 1;
audio.currentTime = Math.floor(Math.random() * max);
}
</script>
</body>
That is how my Code looks like. I know that it works on normal audio, but with the embedded audio nothing happens.
Maybe you could help me.