def getCurrentConditions(self): self.Condition['playTV'] = bool( xbmc.getCondVisibility('Pvr.isPlayingTv')) self.Condition['playVideo'] = bool( xbmc.getCondVisibility('Player.HasVideo') and xbmc.getCondVisibility('Player.Playing')) self.Condition['playAudio'] = bool( xbmc.getCondVisibility('Player.HasAudio') and xbmc.getCondVisibility('Player.Playing')) self.Condition['paused'] = bool( xbmc.getCondVisibility('Player.Paused')) self.Condition['muted'] = bool(xbmc.getCondVisibility('Player.Muted')) # Get the Volume query = { "jsonrpc": "2.0", "method": "Application.GetProperties", "params": { "properties": ["volume"] }, "id": 1 } res = tools.jsonrpc(query) if 'result' in res and 'volume' in res['result']: self.Condition['volume'] = int(res['result'].get('volume')) return self.Condition
def setVolume(cls, volume): query = { "method": "Application.SetVolume", "params": { "volume": int(volume) } } return tools.jsonrpc(query)
def countDown(cls, counter=5): __bar = 0 __percent = 0 __counter = counter __idleTime = xbmc.getGlobalIdleTime() # deactivate screensaver (send key select) if xbmc.getCondVisibility('System.ScreenSaverActive'): query = {"method": "Input.Select"} tools.jsonrpc(query) if xbmc.getCondVisibility('VideoPlayer.isFullscreen'): tools.writeLog('Countdown possibly invisible (fullscreen mode)') tools.writeLog('Showing additional notification') tools.Notify().notify(__LS__(30010), __LS__(30011) % (__counter)) # show countdown tools.writeLog('Display countdown dialog for %s secs' % __counter) pb = xbmcgui.DialogProgressBG() pb.create(__LS__(30010), __LS__(30011) % __counter) pb.update(__percent) # actualize progressbar while __bar <= __counter: __percent = int(__bar * 100 / __counter) pb.update(__percent, __LS__(30010), __LS__(30011) % (__counter - __bar)) if __idleTime > xbmc.getGlobalIdleTime(): tools.writeLog('Countdown aborted by user', level=xbmc.LOGNOTICE) pb.close() return True xbmc.sleep(1000) __idleTime += 1 __bar += 1 pb.close() return False
def setVolume(self, volume): query = { "jsonrpc": "2.0", "method": "Application.SetVolume", "params": { "volume": volume }, "id": 1 } res = tools.jsonrpc(query) if 'result' in res: return res['result']
def getCurrentConditions(cls): _cond = dict() _cond['playTV'] = bool(xbmc.getCondVisibility('Pvr.isPlayingTv')) _cond['playVideo'] = bool( xbmc.getCondVisibility('Player.HasVideo') and xbmc.getCondVisibility('Player.Playing')) _cond['playAudio'] = bool( xbmc.getCondVisibility('Player.HasAudio') and xbmc.getCondVisibility('Player.Playing')) _cond['paused'] = bool(xbmc.getCondVisibility('Player.Paused')) _cond['muted'] = bool(xbmc.getCondVisibility('Player.Muted')) _cond['volChanged'] = False # Get the Volume query = { "method": "Application.GetProperties", "params": { "properties": ["volume"] } } res = tools.jsonrpc(query) if res is not None: _cond['volume'] = res.get('volume', 0) return _cond
def disableScreensaver(): # deactivate screensaver (send key select) if xbmc.getCondVisibility('System.ScreenSaverActive'): query = {"method": "Input.Select"} tools.jsonrpc(query)