So I've made a simple custom progress bar for an audio object within my website. The progress bar works fine, but I've noticed it is very choppy. I also noticed that on websites such as Facebook and YouTube, their progress bar transitions seem to be exceptionally smooth (watch any video and you'll see what I mean).
I thought a workaround to this might be to use some crafty JavaScript and CSS, but in the end it just seemed very tacky, CPU heavy for no reason and looked essentially exactly the same as before. (This is what I came up with):
setInterval(function(){
var rect = elapsedContainer.getBoundingClientRect();
var percentage = audio.currentTime / audio.duration;
elapsed.style.width = (percentage * rect.width) + "px";
}, 33); // 30fps
.elapsed-container{
width: 100%;
height: 10px;
background: grey;
}
.elapsed{
left: 0;
height: 100%;
background: red;
transition: width 33ms linear;
}
All help is appreciated, cheers.