home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
70.15k stars 29.18k forks source link

Roku Progress Bar #107702

Closed jhemak closed 2 months ago

jhemak commented 6 months ago

The problem

When playing content from Roku, the progress bar shown in both the built-in media player card as well as the mini media player do not seem to reflect actual progress while content is playing, however when content is paused the bar jumps to the correct position. Upon resuming play, the bar jumps back to the original (incorrect) position. In one instance, I saw the bar at 100% when just starting content. In other cases, it wasn't quite 100% but still much further ahead than the content actually was. In both cases, pausing the content caused the progress bar to temporarily jump to the correct position. The behavior is identical with both media player cards.

While Playing: image

While Paused: image

What version of Home Assistant Core has the issue?

core-2024.1.2

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant OS

Integration causing the issue

Roku

Link to integration documentation on our website

https://www.home-assistant.io/integrations/roku/

Diagnostics information

No response

Example YAML snippet

No response

Anything in the logs that might be useful for us?

These fields are populated on the Roku media player both while the content is being played and while it's being paused:

media_duration: 9678
media_position: 2353
media_position_updated_at: "2024-01-10T03:47:46.195789+00:00"

Additional information

No response

home-assistant[bot] commented 6 months ago

Hey there @ctalkington, mind taking a look at this issue as it has been labeled with an integration (roku) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `roku` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign roku` Removes the current integration label and assignees on the issue, add the integration domain after the command. - `@home-assistant add-label needs-more-information` Add a label (needs-more-information, problem in dependency, problem in custom component) to the issue. - `@home-assistant remove-label needs-more-information` Remove a label (needs-more-information, problem in dependency, problem in custom component) on the issue.

(message by CodeOwnersMention)


roku documentation roku source (message by IssueLinks)

ctalkington commented 4 months ago

pause triggers an update of polled data. that would explain the update of progress on pause.

Since we poll, we track the duration, position, and time at which that position was updated. This should be enough to simulate an accurate playback progress. unless something has changed in the front-end cards or widgets.

Has this happened in older versions of HomeAssistant? or something new in 2024? Are you doing anything to customize the Polling intervals (10s default)?

ctalkington commented 4 months ago

also did this content have ads? I wonder if that could be making progress appear further since we assume constant playback for progress purposes

jhemak commented 4 months ago

Hello, thanks for the follow up on this. No ads in the content, no custom polling, and I can't say that it ever worked for me as I've only been using HA for a few months. I just tried another test today and confirmed a couple things. My test used both the native Media Control card as well as the Mini Media Player custom card.

(1) When I played the content, the progress bar on both cards was at 100%. Here are three attributes from the Roku media player at that time:

media_duration: 658 media_position: 81 media_position_updated_at: "2024-03-19T22:18:13.650708+00:00"

(2) When I pressed pause, the progress bar on both cards immediately dropped to something like 10% ... much closer to the actual progress of the content that had been playing. Here are the attributes at that point:

media_duration: 658 media_position: 99 media_position_updated_at: "2024-03-19T22:18:13.650708+00:00"

(3) And then I play again. Right back to 100% on the progress bar, with these attributes:

media_duration: 658 media_position: 109 media_position_updated_at: "2024-03-19T22:18:13.650708+00:00"

Is it strange and/or relevant that media_position_updated_at is the same all three times?

jhemak commented 4 months ago

@ctalkington - any thoughts based on the above?

ctalkington commented 4 months ago

the media_position_updated_at could be the culprit. as it would cause the whole progress equation to be wrong. I don't know what the actual time was but what's suppose to happen is time between updated_at and now is suppose to be added to the position so if the position changes but the timestamp doesn't you are definitely out of sync.

jhemak commented 4 months ago

That makes sense. If this is something you are able to fix I would be happy to help test. Thank you!

jhemak commented 2 months ago

Thank you for fixing this @ctalkington! It’s working perfectly now.