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

ERROR: KeyError: 'volume' on Startup 2.0.8 #41

Open
stuckinger opened this issue Oct 3, 2019 · 2 comments
Open

ERROR: KeyError: 'volume' on Startup 2.0.8 #41

stuckinger opened this issue Oct 3, 2019 · 2 comments

Comments

@stuckinger
Copy link

Addon shows error without information on startup, telling me to have a look into the logfile:

ERROR: Traceback (most recent call last):
ERROR: File "/home/osmc/.kodi/addons/script.mpdc/resources/lib/gui.py", line 219, in _connect
ERROR: self._handle_changes(self.client,['mixer','playlist','player','options'])
ERROR: File "/home/osmc/.kodi/addons/script.mpdc/resources/lib/gui.py", line 636, in _handle_changes
ERROR: self._update_volume(state)
ERROR: File "/home/osmc/.kodi/addons/script.mpdc/resources/lib/gui.py", line 610, in _update_volume
ERROR: if state['volume']=='-1':
ERROR: KeyError: 'volume'

Environment:
MPD Client from Repo is 2.0.8
OSMC July 2019 2019.07-1
Linux version 4.14.78-4-osmc (root@vero3-db) (gcc version 6.3.0 20170516 (Debian 6.3.0-18+deb9u1)) #1 SMP PREEMPT Wed Dec 12 17:58:11 UTC 2018
Hardware: RasperryPi 3 B

Anny suggestions?

@bisanz1
Copy link

bisanz1 commented Mar 1, 2020

You could patch /storage/.kodi/addons/script.mpdc/resources/lib/gui.py:

610,616c610,620
<               if state['volume']=='-1':
<                       self.getControl(VOLUME_GROUP).setVisible(False)
<                       self._can_volume=False
<               else:
<                       self._can_volume=True
<                       self.getControl(VOLUME_GROUP).setVisible(True)
<                       self.getControl(VOLUME_STATUS).setPercent(int(state['volume']))
---
>                 try:
>                       if state['volume']=='-1':
>                               self.getControl(VOLUME_GROUP).setVisible(False)
>                               self._can_volume=False
>                       else:
>                               self._can_volume=True
>                               self.getControl(VOLUME_GROUP).setVisible(True)
>                               self.getControl(VOLUME_STATUS).setPercent(int(state['volume']))
>                 except:
>                       self.getControl(VOLUME_GROUP).setVisible(False)
>                       self._can_volume=False

The problem is that mpd apparently does not send "volume=-1" anymore when there is no volume parameter anymore. The "except" part handles this, the same way the "if" block does.

@bisanz1
Copy link

bisanz1 commented Mar 1, 2020

Found at least a 2nd similar code part to be fixed, in order to be able to start the MPD client when mpd is already playing:

866,873c870,880
<                       player = xbmc.Player(xbmc.PLAYER_CORE_MPLAYER)
<                       if player.isPlayingVideo():
<                               return
<                       if player.isPlayingAudio():
<                               if not player.getPlayingFile() == self.stream_url:
<                                       self._start_media_player()
<                       else:
<                               self._start_media_player()
---
>                         try:
>                               player = xbmc.Player(xbmc.PLAYER_CORE_MPLAYER)
>                               if player.isPlayingVideo():
>                                       return
>                               if player.isPlayingAudio():
>                                       if not player.getPlayingFile() == self.stream_url:
>                                               self._start_media_player()
>                                       else:
>                                               self._start_media_player()
>                         except:
>                                 return

spk added a commit to spk/xbmc-plugin-mpdc that referenced this issue Jul 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants