const div = document.querySelectorAll('div');
const colors = [ 'red','blue','yellow','green' ];
div.forEach((el, index) => {
el.style.width = '200px';
el.style.height = '50px';
el.style.border = '1px solid gray'
el.style.backgroundColor = colors[index];
});
var audio = new Audio();
audio.src = "http://mus.com/song.mp3";
audio.play();
var lirycs = [{
"time": 5444,
"duration": 121,
"text": "Top ",
"isLineEnding": 0
},
{
"time": 6000,
"duration": 121,
"text": "Top2 ",
"isLineEnding": 0
}];
var next_text = lirycs.shift();
var checker = setInterval(function(){
if(next_text.time<audio.currentTime*1000){
console.log(next_text.text);
next_text = lirycs.shift();
}
if(audio.ended)clearInterval(checker);
});