Open erinarbleizez opened 6 years ago
@erinarbleizez I'm having this issue too. I tested in a python shell and I can get back a proper status from media_controller.status, track info and all. When I run a script I'm writing in PyCharm CE, I get back what you have shown above.
Python 3.6.5 running in a virtualenv on MacOS, ChromeCast audio.
I can see this was a while ago now but did you get to the bottom of this issue?
If anyone else comes across this issue, try adding time.sleep(1)
before your call to media_controller.status
- This ended up solving this issue for me.
Hello, I think I'm experiencing similar problems. I'm using the first (and only?) Chromecast Audio device.
In my case I'm playing a sequence of songs. My intention is to play the next song when I receive the media status update that the previous song is finished.
When the previous song finishes, by enabling logging, this message is received from the Chromecast
DEBUG:pychromecast.socket_client:Received: Message urn:x-cast:com.google.cast.media from 46e5ee83-49f8-4a1a-b3d7-178af713f74f to *: {'type': 'MEDIA_STATUS', 'status': [{'mediaSessionId': 7, 'playbackRate': 1, 'playerState': 'IDLE', 'currentTime': 0, 'supportedMediaCommands': 274447, 'volume': {'level': 1, 'muted': False}, 'currentItemId': 7, 'idleReason': 'FINISHED'}], 'requestId': 0}
This causes the internal media_controller status object to be updated to playerState = IDLE idleReason = FINISHED contentId = previous track
Then I submit the next track
[ Wed Sep 5 00:49:05 2018 ] Playing http://192.168.1.90:8000/Clip%204.ogg.flac
INFO:pychromecast.controllers:Not launching app CC1AD845 - already running DEBUG:pychromecast.socket_client:Sending: Message urn:x-cast:com.google.cast.media from sender-0 to 46e5ee83-49f8-4a1a-b3d7-178af713f74f: {'media': {'contentId': 'http://192.168.1.90:8000/Clip%204.ogg.flac', 'streamType': 'BUFFERED', 'contentType': 'audio/flac', 'metadata': {}}, 'type': 'LOAD', 'currentTime': 0, 'autoplay': True, 'customData': {}, 'requestId': 6, 'sessionId': '46e5ee83-49f8-4a1a-b3d7-178af713f74f'}
and the following message is received immediately
DEBUG:pychromecast.socket_client:Received: Message urn:x-cast:com.google.cast.media from 46e5ee83-49f8-4a1a-b3d7-178af713f74f to *: {'type': 'MEDIA_STATUS', 'status': [{'mediaSessionId': 8, 'playbackRate': 1, 'playerState': 'IDLE', 'currentTime': 0, 'supportedMediaCommands': 274447, 'volume': {'level': 1, 'muted': False}, 'media': {'contentId': 'http://192.168.1.90:8000/Clip%204.ogg.flac', 'streamType': 'BUFFERED', 'contentType': 'audio/flac', 'metadata': {}}, 'currentItemId': 8, 'extendedStatus': {'playerState': 'LOADING', 'media': {'contentId': 'http://192.168.1.90:8000/Clip%204.ogg.flac', 'streamType': 'BUFFERED', 'contentType': 'audio/flac', 'metadata': {}}}, 'repeatMode': 'REPEAT_OFF'}], 'requestId': 0}
note that the playerState is still IDLE but there's an extendedStatus structure that is completely ignored by the library containg an playerState LOADING update. This way the internal status is updated this way
playerState = IDLE idleReason = FINISHED contentId = next track
and this new status is delivered to the registered listeners, which of course is totally misleading.
Best Regards, Carlo.
Naively, by inserting the following code in the update method in media.py things get much better:
extended_status_data = status_data.get('extendedStatus')
if extended_status_data:
data ['status'] = [extended_status_data]
self.update (data)
Hello, I also had this issue. I use Pychromecast v7.5.1 https://github.com/home-assistant-libs/pychromecast/commit/7c2bec4af3eedd236c4295a750ea60d3798e1313
DEBUG : 2020-10-22 09:59:51,328 : [(xxx.xxx.xxx.xxx):8009] Received: Message urn:x-cast:com.google.cast.media from c3f10024-d44e-418a-9cbc-e989533a19dd to *: {'type': 'MEDIA_STATUS', 'status': [{'mediaSessionId': 2, 'playbackRate': 1, 'playerState': 'IDLE', 'currentTime': 0, 'supportedMediaCommands': 274447, 'volume': {'level': 1, 'muted': False}, 'media': {'contentId': 'http://xxx.xxx.xxx.xxx/media/sample_media.mp4', 'streamType': 'BUFFERED', 'contentType': 'video/mp4', 'metadata': {}, 'mediaCategory': 'VIDEO'}, 'currentItemId': 1, 'extendedStatus': {'playerState': 'LOADING', 'media': {'contentId': 'http://xxx.xxx.xxx.xxx/media/sample_media.mp4', 'streamType': 'BUFFERED', 'contentType': 'video/mp4', 'metadata': {}, 'mediaCategory': 'VIDEO'}, 'mediaSessionId': 2}, 'repeatMode': 'REPEAT_OFF'}], 'requestId': 0}
DEBUG : 2020-10-22 09:59:51,328 : Media:Received status {'type': 'MEDIA_STATUS', 'status': [{'mediaSessionId': 2, 'playbackRate': 1, 'playerState': 'IDLE', 'currentTime': 0, 'supportedMediaCommands': 274447, 'volume': {'level': 1, 'muted': False}, 'media': {'contentId': 'http://xxx.xxx.xxx.xxx/media/sample_media.mp4', 'streamType': 'BUFFERED', 'contentType': 'video/mp4', 'metadata': {}, 'mediaCategory': 'VIDEO'}, 'currentItemId': 1, 'extendedStatus': {'playerState': 'LOADING', 'media': {'contentId': 'http://xxx.xxx.xxx.xxx/media/sample_media.mp4', 'streamType': 'BUFFERED', 'contentType': 'video/mp4', 'metadata': {}, 'mediaCategory': 'VIDEO'}, 'mediaSessionId': 2}, 'repeatMode': 'REPEAT_OFF'}], 'requestId': 0}
I did the following code in the update method in media.py. L. 287
extended_status = status_data.get("extendedStatus", {})
self.player_state = extended_status.get("playerState", self.player_state)
media_data = extended_status.get("media") or {}
self.media_session_id = extended_status.get("mediaSessionId", self.media_session_id)
self.content_id = media_data.get("contentId", self.content_id)
self.content_type = media_data.get("contentType", self.content_type)
self.duration = media_data.get("duration", self.duration)
self.stream_type = media_data.get("streamType", self.stream_type)
self.media_custom_data = media_data.get("customData", self.media_custom_data)
self.media_metadata = media_data.get("metadata", self.media_metadata)
self.subtitle_tracks = media_data.get("tracks", self.subtitle_tracks)
And I also added the following property.
@property
def player_is_loading(self):
""" Return True if player is LOADING. """
return self.player_state == MEDIA_PLAYER_STATE_LOADING
I thought about the extendedStatus parameter based on the following URI, but I'm not sure if this is correct. https://developers.google.com/cast/docs/reference/web_receiver/cast.framework.messages.ExtendedMediaStatus
Hi,
I try to make a cron task that send video when the chromecast is not used. I tried this code that work to send video
I receive the right status right after starting the video:
but when I restart the script while the videos are playing to check the status I get this:
I tried with 1 chromecast v1, 1 chromecast v2 and 2 chromecast ultra, same result
did I missed something?