Youtube app returning outdated playing
What to investigate?
During my investigation I found out that playing something using built in youtube app keeps that playing data until restart of pyatv and reconnection. Steps to reproduce:
- Start youtube playback using remote. Playing showing correct data:
- Navigate to home screen. Playing still showing youtube playback with "paused" state.
- Start airplay spotify playback. Correct data is displayed.
- Disconnect from airplay. Playing reverts back to youtube.
- Restart pyatv service and fetch playing again. It's showing correct Idle state.
After digging into source code found that MRP active_player is always going back to com.google.ios.youtube when youtube was playing and appletv is now on home screen. Killing youtube app from background fixes it.
It seems to be working okish with this logic but ofc it's just nasty workaround.
I know that's probably MRP protobuf behaviour but maybe there is a way to fix that?
If not is there a way to pull for playback of active player using some protobuf command? I was trying to execute
# This should be the first message sent after encryption has
# been enabled
await self.send(messages.set_connection_state())
# Subscribe to updates at this stage
await self.send_and_receive(messages.client_updates_config())
in interval but seems it gives a feedback only once after initial command is sent.
Expected outcome
Youtube app not showing a playing after closing/moving to background
Good investigation, there's probably a bug in MRP. Can you verify how iOS works?
Ahhh.. good one. Just did a test and seems like it's (not)working in the same way so I guess nothing we can do with that.
Do you maybe know if we can force AppleTV to return contentItems via MRP?
I tried SET_STATE_MESSAGE: ProtocolMessage._Type.ValueType # 4 but seems like it's working once after connection and then it's just auto returned if something change.
If that would be possible I could implement some mechanism to poll for content items when youtube is opened as it's not giving feedback automatically when you stop a video (still showing old playback).