本文整理汇总了Python中soco.SoCo.ramp_to_volume方法的典型用法代码示例。如果您正苦于以下问题:Python SoCo.ramp_to_volume方法的具体用法?Python SoCo.ramp_to_volume怎么用?Python SoCo.ramp_to_volume使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类soco.SoCo
的用法示例。
在下文中一共展示了SoCo.ramp_to_volume方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Song
# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import ramp_to_volume [as 别名]
try:
playback_state = sonos.get_current_transport_info()['current_transport_state']
if playback_state == 'STOPPED':
sonos.play()
elif playback_state == 'PLAYING':
sonos.pause()
except SoCoUPnPException as e:
print '[{"icon": "font-awesome:times-circle", "title": "Not supported by current zone."}]'
elif action == 'v+5':
# Increase volume
current_vol = sonos.volume
new_vol = current_vol + 5
if new_vol > 100:
new_vol = 100
sonos.ramp_to_volume(new_vol)
elif action == 'v-5':
# Decrease volume
current_vol = sonos.volume
new_vol = current_vol - 5
if new_vol < 0:
new_vol = 0
sonos.ramp_to_volume(new_vol)
elif action == 'mute':
# Mute Volume
sonos.volume = 0
elif action == 'next':
# Next Song (might be unsupported by playback source e.g. streams)