I'm not sure how you start your marquee trick, but you should wait for the play
event of your audio element. Autoplay fires this event when an element starts playing.
Note that the marquee
-tag parameter is deprecated, instead I would use css transitions that can be easily triggered by adding a specific class name.
Give the media element an identifier so that you can easily access it using javascript:
<audio id="audio" controls="controls" loop="loop"> <source src="song.ogg" type="audio/ogg" /> <source src="song.mp3" type="audio/mpeg" /> Your browser does not support the audio element.Please use chrome. </audio>
And the JavaScript code:
var audioEl = document.getElementById("audio"); audioEl.addEventListener('play',function(){
You can find all the events that are supported by media items on the W3C page , with a description of when they are fired. This gives you an overview of how you can interact with media elements in javascript.
GNi33 source share