damianeickhoff / HaCasa

Custom theme and cards for Home Assistant
https://damianeickhoff.github.io/HaCasa/
MIT License
60 stars 6 forks source link

Real-Time media player progress bar #16

Open damianeickhoff opened 5 months ago

damianeickhoff commented 5 months ago

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
`
ngocjohn commented 1 day ago

https://community.home-assistant.io/t/hacasa-a-new-modern-dashboard/744334/19