pyatv: push updates is broken when seeking media

Describe the bug

I have discovered that push updates gives incorrect information when seeking media on another source. I have reproduced this on Disney Plus & Netflix. I discovered this initially through the home assistant integration, and then I reproduced it using pyatv on the command line.

Error log

There is no error, it is a silent corruption.

How to reproduce the bug?

Use atvscript --id ... --airplay-credentials ... push_updates in one terminal. Use atvremote --id ... --airplay-credentials ... playing in another terminal.

Start to play a show on Disney Plus. You can see that atvscript shows that playback has begun, and it shows the correct position. You can also run atvremote and see that it shows the correct position.

Next, using the apple TV remote or home assistant integration, seek to a new position. Pause & unpause the show. You can see that atvremote shows the correct & updated position. However, although atvscript will have got push updates for the playing/paused state, it will have the old position plus the duration of playback since seeking.

What is expected behavior?

The pushed updates should register the new position after seeking.

Operating System

macOS & homeassistant haos

Python

3.6

pyatv

0.10.3

Device

Apple TV 4k OS 16.3.1

Additional context

I will investigate more to see if I can identify a line of code to change.

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Comments: 26 (5 by maintainers)

Most upvoted comments

I would love to see this propagate through here to home assistant; it’d be really valuable there! On Feb 1, 2024 at 1:10 PM -0500, Michael Schwartz @.***>, wrote:

FYI, I came up with a hack-ish fix that mostly works. In my server code, I keep a “last_position” variable. When the device state goes “paused”, the last_position is set - the position value retrieved via the API when the device is paused is correct (the only time it is). Since I am polling 1/sec, I just update the last_position and send that to my clients. It’s the value I want, 99% of the time. It does get out of sync some of the time (like when YouTube automatically moves to the next video it never goes into paused state). The way to sync it up is to hit pause on my remote. In case someone else has a need for this kind of fix. — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>