postlund / pyatv

A client library for Apple TV and AirPlay devices
https://pyatv.dev
MIT License
886 stars 100 forks source link

Odd pause/play behavior #1875

Open mschwartz opened 1 year ago

mschwartz commented 1 year ago

Describe the bug

When I start watching a program (Computers App, for example) the position and total_time values are correct.

But if I pause the program with the remote, the position jumps back a decent number of seconds and the position and total_times stay at those values, as if paused.

When I resume the program, say 2 minutes later, the position jumps ahead 2 minutes even though the media isn't playing.

This results in the position hitting the total_time 2 minutes before the show is actually over.

If I restart pyatv, everything gets back in sync.

Please advise on any commands you want me to run to help debug this.

Error log

<place log here>

Nothing to post.

How to reproduce the bug?

Watch a show, print out the position and total_time values.

Pause the show and observe the behavior described.

Resume the show and see if the times are off.

What is expected behavior?

Pause should not jump the position back. Resume should not jump ahead the amount of time paused.

Operating System

Linux

Python

3.10

pyatv

Whatever pip install pyatv installs

Device

AppleTV latest tvOS

Additional context

Things have been a bit wonky since the major version update to the ATVs.

Prior, my code was working perfectly fine.

mschwartz commented 1 year ago

My code simply polls the ATV once per second and sends the returned data via MQTT.

I know enough python to do this. No major projects using it otherwise.

2022-11-15 at 4 25 PM

...

2022-11-15 at 4 25 PM

mschwartz commented 1 year ago

I rewrote my python code after learning more python programming than I cared to learn 😀

the code is much cleaner.

The issue persists in the new version.

there are also a couple of other issues.

After running for a long time, like days, I eventually see messages like “power is blocked” and I have to restart the program and it works again.

The second is related to the first. If I reboot the Apple TV while connected, I don’t know of any indication to the software that this happened. I would love to see an option to reconnect automatically on connection lost and on errors like the blocked one.

Thanks for all the great work on this, and for your excellent support!

mschwartz commented 1 year ago

It’s really messed up when scrubbing (drag position knob, joypad up, then right to go way forward).

A 45 minute program shows 1:00 after a minute. Scrub to the 40 minute mark and the position is still 1:00.

Restart of my pyatv app gets the right results again, until pause or scrub.

I am polling once a second, looking at the metadata and metadata.playing() data.