本文整理汇总了Python中resources.lib.settings.Settings.getAvoidDuplicateCommands方法的典型用法代码示例。如果您正苦于以下问题:Python Settings.getAvoidDuplicateCommands方法的具体用法?Python Settings.getAvoidDuplicateCommands怎么用?Python Settings.getAvoidDuplicateCommands使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类resources.lib.settings.Settings
的用法示例。
在下文中一共展示了Settings.getAvoidDuplicateCommands方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: _canProcessFilteredAction
# 需要导入模块: from resources.lib.settings import Settings [as 别名]
# 或者: from resources.lib.settings.Settings import getAvoidDuplicateCommands [as 别名]
def _canProcessFilteredAction(self):
currentTime = time.time()
# Make sure we are not in a blackout zone
if currentTime > self.nextFilteredAction:
# Reset the time, and make sure we do not process any others
# for another 2 seconds (This will prevent a large build up
# as we hope that the sonos system can process this within
# 2 seconds, otherwise there will be a delay)
self.nextFilteredAction = currentTime + Settings.getAvoidDuplicateCommands()
return True
elif self.nextFilteredAction > 0:
log("SonosControllerWindow: Ignoring commands until %s" % time.strftime("%H:%M:%S", time.gmtime(self.nextFilteredAction)))
return False
示例2: onAction
# 需要导入模块: from resources.lib.settings import Settings [as 别名]
# 或者: from resources.lib.settings.Settings import getAvoidDuplicateCommands [as 别名]
def onAction(self, action):
# actioncodes from https://github.com/xbmc/xbmc/blob/master/xbmc/guilib/Key.h
ACTION_PREVIOUS_MENU = 10
ACTION_NAV_BACK = 92
# For remote control
ACTION_PAUSE = 12
ACTION_STOP = 13
ACTION_NEXT_ITEM = 14
ACTION_PREV_ITEM = 15
# The following 4 are active forward and back
ACTION_FORWARD = 16
ACTION_REWIND = 17
ACTION_PLAYER_FORWARD = 77
ACTION_PLAYER_REWIND = 78
ACTION_PLAYER_PLAY = 79
ACTION_VOLUME_UP = 88
ACTION_VOLUME_DOWN = 89
ACTION_MUTE = 91
# Values Used in the custom keymap
ACTION_FIRST_PAGE = 159 # Next Track
ACTION_LAST_PAGE = 160 # Previous Track
ACTION_PAGE_UP = 5 # Increase Volume
ACTION_PAGE_DOWN = 6 # Decrease Volume
ACTION_TOGGLE_WATCHED = 200 # Mute volume
if (action == ACTION_PREVIOUS_MENU) or (action == ACTION_NAV_BACK):
log("SonosControllerWindow: Close Action received: %s" % str(action.getId()))
self.close()
else:
# Handle remote control commands
if((action == ACTION_PLAYER_PLAY) or (action == ACTION_PAUSE)):
# Get the initial state of the device
playStatus = self.sonosDevice.get_current_transport_info()
# Play/pause is a toggle, so pause if playing
if playStatus is not None:
if playStatus['current_transport_state'] == 'PLAYING':
self.onClick(SonosControllerWindow.BUTTON_PAUSE)
else:
self.onClick(SonosControllerWindow.BUTTON_PLAY)
elif (action == ACTION_STOP):
self.onClick(SonosControllerWindow.BUTTON_STOP)
elif (action == ACTION_NEXT_ITEM) or (action == ACTION_FIRST_PAGE):
self.onClick(SonosControllerWindow.BUTTON_NEXT)
elif (action == ACTION_PREV_ITEM) or (action == ACTION_LAST_PAGE):
self.onClick(SonosControllerWindow.BUTTON_PREVIOUS)
elif (action == ACTION_MUTE) or (action == ACTION_TOGGLE_WATCHED):
# Check if currently muted
if self.sonosDevice.mute is False:
self.onClick(SonosControllerWindow.BUTTON_NOT_MUTED)
else:
self.onClick(SonosControllerWindow.BUTTON_MUTED)
elif (action == ACTION_VOLUME_UP) or (action == ACTION_PAGE_UP):
# Get the current slider position
volumeSlider = self.getControl(SonosControllerWindow.SLIDER_VOLUME)
currentSliderPosition = int(volumeSlider.getPercent())
if currentSliderPosition < 100:
# Bump the volume by double the wait time (otherwise we can't skip forward accurately)
volumeSlider.setPercent(currentSliderPosition + Settings.getVolumeChangeIncrements())
self.onClick(SonosControllerWindow.SLIDER_VOLUME)
elif (action == ACTION_VOLUME_DOWN) or (action == ACTION_PAGE_DOWN):
# Get the current slider position
volumeSlider = self.getControl(SonosControllerWindow.SLIDER_VOLUME)
currentSliderPosition = int(volumeSlider.getPercent())
if currentSliderPosition > 0:
# Bump the volume down by double the wait time (otherwise we can't skip forward accurately)
volumeSlider.setPercent(currentSliderPosition - Settings.getVolumeChangeIncrements())
self.onClick(SonosControllerWindow.SLIDER_VOLUME)
elif((action == ACTION_FORWARD) or (action == ACTION_PLAYER_FORWARD)):
# Get the current slider position
seekSlider = self.getControl(SonosControllerWindow.SLIDER_SEEK)
currentSliderPosition = int(seekSlider.getPercent())
if currentSliderPosition < 99:
# Bump the slider by double the wait time (otherwise we can't skip forward accurately)
seekSlider.setPercent(currentSliderPosition + (int(Settings.getAvoidDuplicateCommands()) * 2))
self.onClick(SonosControllerWindow.SLIDER_SEEK)
elif((action == ACTION_REWIND) or (action == ACTION_PLAYER_REWIND)):
# Get the current slider position
seekSlider = self.getControl(SonosControllerWindow.SLIDER_SEEK)
currentSliderPosition = int(seekSlider.getPercent())
if currentSliderPosition > 0:
# Bump the slider down by double the wait time (otherwise we can't skip forward accurately)
seekSlider.setPercent(currentSliderPosition - (int(Settings.getAvoidDuplicateCommands()) * 2))
self.onClick(SonosControllerWindow.SLIDER_SEEK)