diff --git a/resources/language/English/strings.xml b/resources/language/English/strings.xml index 8212a20..7b795e4 100644 --- a/resources/language/English/strings.xml +++ b/resources/language/English/strings.xml @@ -41,7 +41,10 @@ Port User Password - Stop all torrents on video playback + Action on video playback + None + Pause all torrents + Enable Temporary Speed Limits An unexpected error occurred diff --git a/resources/lib/common.py b/resources/lib/common.py index f73b51d..5285066 100644 --- a/resources/lib/common.py +++ b/resources/lib/common.py @@ -12,7 +12,7 @@ def get_settings(): 'port': __settings__.getSetting('rpc_port'), 'user': __settings__.getSetting('rpc_user'), 'password': __settings__.getSetting('rpc_password'), - 'stop_all_on_playback': __settings__.getSetting('stop_all_on_playback') + 'action_on_playback': __settings__.getSetting('action_on_playback') } return params diff --git a/resources/lib/player.py b/resources/lib/player.py index c53b102..f9b15e3 100644 --- a/resources/lib/player.py +++ b/resources/lib/player.py @@ -21,13 +21,18 @@ class SubstitutePlayer(xbmc.Player): def onPlayBackStarted(self): self.refreshSettings() - if self.active and xbmc.Player().isPlayingVideo(): - self.stopAllTorrents() + if self.mode != '0' and xbmc.Player().isPlayingVideo(): + if self.mode == '1': + self.stopAllTorrents() + elif self.mode == '2': + self.enableSpeedLimit() def onPlayBackStopped(self): self.refreshSettings() - if self.active: + if self.mode == '1': self.startAllTorrents() + elif self.mode == '2': + self.disableSpeedLimit() def startAllTorrents(self): if self.transmission: @@ -41,10 +46,18 @@ class SubstitutePlayer(xbmc.Player): for tid, torrent in torrents.iteritems(): self.transmission.stop(tid) + def enableSpeedLimit(self): + if self.transmission: + self.transmission.set_session(alt_speed_enabled=True) + + def disableSpeedLimit(self): + if self.transmission: + self.transmission.set_session(alt_speed_enabled=False) + def refreshSettings(self): settings = common.get_settings() if settings != self.prev_settings: - self.active = (settings['stop_all_on_playback'] == 'true') + self.mode = settings['action_on_playback'] try: self.transmission = common.get_rpc_client() except: diff --git a/resources/settings.xml b/resources/settings.xml index 2d2053d..3eac296 100644 --- a/resources/settings.xml +++ b/resources/settings.xml @@ -5,5 +5,5 @@ - +