home-assistant-libs / pychromecast

Library for Python 3 to communicate with the Google Chromecast.
MIT License
2.52k stars 378 forks source link

Incorrect/incomplete CastStatus and MediaStatus with Youtube #255

Open chocomega opened 5 years ago

chocomega commented 5 years ago

Using PyChromecast 2.1.0 with Home Assistant 0.79.2 Cast firmware version: 1.35.134464 Youtube app version: 13.39.51

Not sure if this is an issue with PyChromecast or HA, but I believe PyChromecast is concerned.

When playing a Youtube video on the Chromecast, the state in HA is not updated. Here is the twist, this issue only happens when the cast is initiated from a notification on my Android phone. A notification "Watch on TV" appears with a suggested video and a button "Play on TV". There's no issue if the cast is initiated manually from the Youtube app.

Some info while playing the video from the notification:

>>> chromecasts[2].status
CastStatus(is_active_input=False, is_stand_by=True, volume_level=0.9134814739227295, volume_muted=False, app_id='YouTube', display_name='YouTube', namespaces=[], session_id='568087bc-d812-4d66-bb53-e6276e17fb3a', transport_id=None, status_text='YouTube on TV')
>>> chromecasts[2].media_controller.status
<MediaStatus {'metadata_type': None, 'title': None, 'series_title': None, 'season': None, 'episode': None, 'artist': None, 'album_name': None, 'album_artist': None, 'track': None, 'subtitle_tracks': {}, 'images': [], 'supports_pause': False, 'supports_seek': False, 'supports_stream_volume': False, 'supports_stream_mute': False, 'supports_skip_forward': False, 'supports_skip_backward': False, 'current_time': 0, 'content_id': None, 'content_type': None, 'duration': None, 'stream_type': 'UNKNOWN', 'idle_reason': None, 'media_session_id': None, 'playback_rate': 1, 'player_state': 'UNKNOWN', 'supported_media_commands': 0, 'volume_level': 1, 'volume_muted': False, 'media_custom_data': {}, 'media_metadata': {}, 'current_subtitle_tracks': [], 'last_updated': None}>

And while playing another video but manually casted:

>>> chromecasts[2].status
CastStatus(is_active_input=False, is_stand_by=True, volume_level=0.8600000143051147, volume_muted=False, app_id='233637DE', display_name='YouTube', namespaces=['urn:x-cast:com.google.cast.debugoverlay', 'urn:x-cast:com.google.cast.cac', 'urn:x-cast:com.google.cast.media', 'urn:x-cast:com.google.youtube.mdx'], session_id='42ec6a74-83d9-4efe-9c7c-d047b7ae747d', transport_id='42ec6a74-83d9-4efe-9c7c-d047b7ae747d', status_text='YouTube')
>>> chromecasts[2].media_controller.status
<MediaStatus {'metadata_type': 0, 'title': 'CGI 3D Animated Short: "Mechanical" - by ESMA', 'series_title': None, 'season': None, 'episode': None, 'artist': None, 'album_name': None, 'album_artist': None, 'track': None, 'subtitle_tracks': {}, 'images': [MediaImage(url='https://i.ytimg.com/vi/sDI2admB0eQ/hqdefault.jpg', height=None, width=None)], 'supports_pause': True, 'supports_seek': True, 'supports_stream_volume': False, 'supports_stream_mute': False, 'supports_skip_forward': False, 'supports_skip_backward': False, 'current_time': 13.874, 'content_id': 'sDI2admB0eQ', 'content_type': 'x-youtube/video', 'duration': 400.841, 'stream_type': 'BUFFERED', 'idle_reason': None, 'media_session_id': 1333990241, 'playback_rate': 1, 'player_state': 'PLAYING', 'supported_media_commands': 3, 'volume_level': 0.8600000143051147, 'volume_muted': False, 'media_custom_data': {}, 'media_metadata': {'metadataType': 0, 'title': 'CGI 3D Animated Short: "Mechanical" - by ESMA', 'subtitle': 'TheCGBros', 'images': [{'url': 'https://i.ytimg.com/vi/sDI2admB0eQ/hqdefault.jpg'}]}, 'current_subtitle_tracks': [], 'last_updated': datetime.datetime(2018, 10, 3, 17, 4, 19, 470151)}>

Steps to reproduce:

Expected result: Complete CastStatus and MediaStatus or at least a state change in HA

chocomega commented 5 years ago

To clarify, the notification looks like this:

screenshot

uudruid74 commented 5 years ago

Not sure if this is related, but I get the same result when my Vizio TV (built-in Chromecast) is casting anything from the its built-in "apps". The main menu on a Vizio is basically an HTML5 page and the apps are just links. Google Assistant thinks nothing is playing on the TV, and I'm guessing the same holds true when starting from a notification. Edit: Sorry, but this is different. Vizio says "is_active_input=True" but shows nothing, where you are getting False.

I was hoping this library would shed some light on things, but now I only have more questions.

Mihara commented 5 years ago

I'm suddenly experiencing something very similar: Videos cast from my phone with the YouTube app result in no MediaStatus updates. Manually invoking casttube to play a video does.