Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add OnResume event to handle play status correctly #14403

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions homeassistant/components/media_player/kodi.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ def __init__(self, hass, name, host, port, tcp_port, encryption=False,
self._ws_server.Player.OnPause = self.async_on_speed_event
self._ws_server.Player.OnPlay = self.async_on_speed_event
self._ws_server.Player.OnSpeedChanged = self.async_on_speed_event
self._ws_server.Player.OnResume = self.async_on_speed_event
self._ws_server.Player.OnStop = self.async_on_stop
self._ws_server.Application.OnVolumeChanged = \
self.async_on_volume_changed
Expand Down Expand Up @@ -392,7 +393,7 @@ def state(self):
if not self._players:
return STATE_IDLE

if self._properties['speed'] == 0 and not self._properties['live']:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see related issue from description

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Seems reasonable enough.

Going to ping @lwis since they added it originally: #4388

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem with this is that the state will change if the stream buffers, so if you're watching something which keeps buffering it'll trigger whatever state change actions you have set (which for me is lights, which quickly becomes annoying)

if self._properties['speed'] == 0:
return STATE_PAUSED

return STATE_PLAYING
Expand Down Expand Up @@ -504,9 +505,8 @@ def media_content_type(self):

If the media type cannot be detected, the player type is used.
"""
if MEDIA_TYPES.get(self._item.get('type')) is None and self._players:
return MEDIA_TYPES.get(self._players[0]['type'])
return MEDIA_TYPES.get(self._item.get('type'))
return self._item.get('title') or self._item.get('label') or self._item.get('file')

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (91 > 79 characters)



@property
def media_duration(self):
Expand Down