postlund / pyatv

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

Wrong state when watching TV. #642

Closed Tobbe82 closed 3 years ago

Tobbe82 commented 4 years ago

When using Telia Play on Apple-TV it report "Paused" instead of "playing"

Should say "playing"

System Setup (please complete the following information):

Skärmklipp

postlund commented 4 years ago

Can you check what the Remote app in iOS says? Additional logs (especially for pyatv) is needed for further debugging.

Tobbe82 commented 4 years ago

442B1409-360D-4C4E-A009-A72C807D7D7A

Where to find the pyatv log?

postlund commented 4 years ago

You can enable it like this:

logger:
  logs:
    pyatv: debug
    custom_components.apple_tv: debug

I suspect it has something to do with live tv. Would be good if you could press play and pause a couple of times so I can see how that affects the state.

Tobbe82 commented 4 years ago

Ill do some tests and will try to get the logger running. But I’ve seen the behavior before when watching TV. Unsure if that was live.. but I’ll return when checked a bit more 👍🏼

postlund commented 4 years ago

@Tobbe82 Did you manage to get any logs?

Tobbe82 commented 4 years ago

Had a very intensive month, just got the logger up, and it grows for every second. Is there a way to get rid of all other stuff in the log or do you want the whole file? Watching TV3 tonight and it does report state as paused as I watch, like it did last time. Tried to change channel to TV4 and seems to still be paused

Tobbe82 commented 4 years ago

Had a very intensive month, just got the logger up, and it grows for every second. Is there a way to get rid of all other stuff in the log or do you want the whole file? Watching TV3 tonight and it does report state as paused as I watch, like it did last time. Tried to change channel to TV4 and seems to still be paused

I fixed it, setting default to critical for the rest.. hope it doesn't ruin anything for pyatv

postlund commented 4 years ago

I fixed it, setting default to critical for the rest.. hope it doesn't ruin anything for pyatv

That is perfect!

Once you have the logs ready, just let me know. If you can provide a time stamp when the state is wrong, that could help me to narrow down where to look.

Tobbe82 commented 4 years ago

Want me to send the file via mail? Could do anytime, have the wrong state during the whole time the logger been up. Actually had time to sit down the evening. Thinking of it... last time was this gala.. live, tonight its Efterlyst and then news on TV4, both of them live? I need to switch channel to something thats not live...

postlund commented 4 years ago

Sure, email works fine! Seems like a good idea to try a few different things to watch, both live and not live. My guess is that it's the live shows that doesn't work.

Tobbe82 commented 4 years ago

Switched to Kanal9, Dunkirk isnt live, but still showing paused.

Tobbe82 commented 4 years ago

Switched to Kanal9, Dunkirk isnt live, but still showing paused.

But iOS remote app actually says Direktsänt even for Dunkirk

Well I sent you the log now

postlund commented 4 years ago

I actually don't see anything strange here, at least when it comes to the play state. Would it be possible for you to install pyatv and run atvremote to check if it reports the same as well? They way I can also provide a variant with additional debug logs.

postlund commented 4 years ago

Ah, no, now I see it. It's because playbackRate is zero. This makes it a bit tricky. Can you reproduce and do play, pause, play, fast forward and play? Just so I can see how it behaves.

KibosJ commented 4 years ago

This happens to me when using Amazon Prime Video, I get "playing" with every app (Netflix, Plex, Infuse, etc.) but Amazon Prime Video shows as "paused" all the time

postlund commented 4 years ago

@KibosJ Would be great if you could provide some logs as well (doing the same thing as instructed in my previous post).

KibosJ commented 4 years ago

So playbackRate is zero on Amazon Prime Video too.

Playing, fast forwarding, rewinding doesn't seem to change the state.

pyatv.log

postlund commented 4 years ago

Thanks for the log @KibosJ! Glanced through it and it looks like the same problem reported by @Tobbe82. Based on what's in the messages, I can provide a hack-ish solution that reports "playing" correctly, but everything else (like seeking) will be reported as "paused". That's the best I can do. Will try to push a PR later tonight, so if any one of you can try it out it would be swell. It's tedious to get it working with the HA component (as I would have to make a pypi release and all that), so using atvremore is recommended.

In the end, I do believe this is really an issue with the app.

KibosJ commented 4 years ago

I think it definitely has to be the app, because a few of them do it, it happens with BBC iPlayer too and it also reports playbackRate as zero.

I've checked some apps like Plex/Infuse and Netflix and they all report playbackRate as 1.0 which according to Apple documentations is the default, 0.0 is an invalid number, so this would need to be fixed by Amazon/BBC, etc.

Thanks for the hack solution though 😁

postlund commented 4 years ago

Great work for looking into that @KibosJ 😊 The fact that this might yield incorrect state updates is something worth adding to the documentation (FAQ). But anyway, good to get it confirmed!

I pushed #673 which mitigates the problem with the solution described above. Feel free to give it a test run!

Tobbe82 commented 4 years ago

I’ve tried to reach out to the developers today at Telia reporting this as a bug in their app. But the dude at customer service didnt seem to bother much... as this was a little more to request than expected from their service 😂 how do I do to try out your fix postlund?

postlund commented 4 years ago

Yeah, these minor things are not always easy to get through 😉

Something like this should work:

$ python3 -m venv pyatv_tmp
$ source pyatv_tmp/bin/activate
$ pip install git+https://github.com/postlund/pyatv.git@refs/heads/playstate_fix
$ atvremote -s <Apple TV IP> playing

Hopefully the correct state should be printed to the terminal

KibosJ commented 4 years ago

Yeah, these minor things are not always easy to get through 😉

Something like this should work:

$ python3 -m venv pyatv_tmp
$ source pyatv_tmp/bin/activate
$ pip install git+https://github.com/postlund/pyatv.git@refs/heads/playstate_fix
$ atvremote -s <Apple TV IP> playing

Hopefully the correct state should be printed to the terminal

Confirmed 🙂

Amazon Prime Video, atvremote output


Device state: Playing
       Title: The Little Things You Do Together
    Position: 4/2617s (0.2%)
      Repeat: Off
     Shuffle: Off
postlund commented 4 years ago

Great @KibosJ, thanks for verifying 👍I'll give @Tobbe82 a chance to try as well 😉

magnus200OK commented 3 years ago

Hi, we've made some bug fixes in the Telia Play app so we correctly report the playback rate for live TV. (MPNowPlayingInfoPropertyPlaybackRate = 1.0 and also fixed wrong media type too). Thanks for letting us know @Tobbe82. The fixes will be done in Telia Play app version 1.32.0 to be release by 17/6 to App Store.

postlund commented 3 years ago

Great @magnus200OK! Thanks for fixing this and reaching out 😀

postlund commented 3 years ago

@Tobbe82 Did you manage to verify my changes as well?

Tobbe82 commented 3 years ago

@Tobbe82 Did you manage to verify my changes as well?

I got an error when trying to install the fix, so haven’t been able to confirm it. Tried two methods of install, I could try tomorrow again and copy the error for you to see?

postlund commented 3 years ago

@Tobbe82 Did you manage to verify my changes as well?

I got an error when trying to install the fix, so haven’t been able to confirm it. Tried two methods of install, I could try tomorrow again and copy the error for you to see?

Yeah, let's do that. Hopefully we can figure out what the problem is!

Tobbe82 commented 3 years ago

Installed the fix and turned the app back to the AppStore-version, can confirm the fix also works for me Well done 👍🏼

postlund commented 3 years ago

That is great! I will merge the PR so we can put this issue to rest!