本文整理汇总了Python中resources.lib.settings.Settings.getVolumeChangeIncrements方法的典型用法代码示例。如果您正苦于以下问题:Python Settings.getVolumeChangeIncrements方法的具体用法?Python Settings.getVolumeChangeIncrements怎么用?Python Settings.getVolumeChangeIncrements使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类resources.lib.settings.Settings
的用法示例。
在下文中一共展示了Settings.getVolumeChangeIncrements方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: checkVolumeChange
# 需要导入模块: from resources.lib.settings import Settings [as 别名]
# 或者: from resources.lib.settings.Settings import getVolumeChangeIncrements [as 别名]
def checkVolumeChange(self):
# Check to see if the Sonos Volume Redirect is Enabled
if not Settings.redirectVolumeControls():
return
self.volumeChangeNotification = self.volumeChangeNotification - 1
redirect = xbmcgui.Window(10000).getProperty("SonosVolumeRedirect")
while redirect not in [None, ""]:
xbmcgui.Window(10000).clearProperty("SonosVolumeRedirect")
volumeChange = 0
isMute = False
if redirect.lower() == "up":
volumeChange = Settings.getVolumeChangeIncrements()
elif redirect.lower() == "down":
volumeChange = Settings.getVolumeChangeIncrements() * -1
elif redirect.lower() == "mute":
isMute = True
log("SonosVolumeRedirect: Changing by %d" % volumeChange)
# Check to see if it has changed, and if we need to change the sonos value
if isMute:
# Check the current muted state
if sonosDevice.mute:
sonosDevice.fullMute(False)
else:
sonosDevice.fullMute(True)
self.volumeChangeNotification = Settings.getChecksPerSecond() * 2
elif volumeChange != 0:
sonosDevice.setGroupVolume(sonosDevice.volume + volumeChange, True)
self.volumeChangeNotification = Settings.getChecksPerSecond() * 2
redirect = xbmcgui.Window(10000).getProperty("SonosVolumeRedirect")
# Check if we have started changing the volume and have now stopped
# for a little while
if self.volumeChangeNotification == 0:
self.volumeChangeNotification = -1
if sonosDevice.mute:
xbmcgui.Dialog().notification(ADDON.getLocalizedString(32074), ADDON.getLocalizedString(32075), ICON, 2000, False)
else:
displayMsg = "%d" % sonosDevice.volume
xbmcgui.Dialog().notification(ADDON.getLocalizedString(32074), displayMsg, ICON, 2000, False)
示例2: onAction
# 需要导入模块: from resources.lib.settings import Settings [as 别名]
# 或者: from resources.lib.settings.Settings import getVolumeChangeIncrements [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)