The progress bar for the media player, for ex. music, isn't real-time. It takes the duration and the progress from the Spotify intergration, but it updates around every 5 to 10 seconds.
What we need is that it takes the duration of the song and just counts from 0 until that duration is reached as long as the song is playing
Current code:
var num = states[entity.entity_id].attributes.media_position;
var den = states[entity.entity_id].attributes.media_duration;
var state = (num / den * 100).toFixed(2)
return `
<div>
<div style="background:var(--color-gold); height: 12px; width:${state}%"
</div>
</div
`
The progress bar for the media player, for ex. music, isn't real-time. It takes the duration and the progress from the Spotify intergration, but it updates around every 5 to 10 seconds.
What we need is that it takes the duration of the song and just counts from 0 until that duration is reached as long as the song is playing
Current code: