本文整理汇总了Python中soco.SoCo.volume方法的典型用法代码示例。如果您正苦于以下问题:Python SoCo.volume方法的具体用法?Python SoCo.volume怎么用?Python SoCo.volume使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类soco.SoCo
的用法示例。
在下文中一共展示了SoCo.volume方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: volume_down
# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import volume [as 别名]
def volume_down(self):
for ip in self._ZONE_IPS:
device = SoCo(ip)
vol = int(device.volume())
if vol > 0:
device.volume(vol-1)
return True
elif vol == 100:
return True
示例2: volume_up
# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import volume [as 别名]
def volume_up(self):
self.logger.info('Raising volume...')
for ip in self._ZONE_IPS:
device = SoCo(ip)
vol = int(device.volume())
if vol < 100:
self.logger.debug('Setting volume to %d', vol+1)
if not device.volume(vol+1):
self.logger.error('Could not set volume at %s.', ip)
return False
else:
self.logger.info('Raised volume.')
return True
elif vol == 100:
self.logger.info('Volume at max, could not raise.')
return True
示例3: bttn_stop
# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import volume [as 别名]
def bttn_stop():
# connect to the Sonos
sonos = SoCo(SONOS_IP)
# connect to Philips Hue Bridge
hue = Bridge(ip=HUE_IP,
username=HUE_USERNAME)
# stop the Sonos and reset to sensible defaults
queue = sonos.get_queue()
sonos.clear_queue()
sonos.volume = 45
sonos.play_mode = 'NORMAL'
sonos.stop()
# set the lights back to approximately 80% over 3 seconds
command = {
'transitiontime': 30,
'on': True,
'bri': 203
}
hue.set_light(1, command)
return jsonify(status="success")
示例4: volume_down
# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import volume [as 别名]
def volume_down(self):
self.logger.info('Lowering volume...')
for ip in self._ZONE_IPS:
device = SoCo(ip)
vol = int(device.volume())
if vol > 0:
self.logger.debug('Setting volume to %d', vol-1)
if not device.volume(vol-1):
self.logger.error('Could not set volume at %s.', ip)
return False
else:
self.logger.error('Lowered volume.')
return True
elif vol == 100:
self.logger.info('Volume at min, could not lower.')
return True
示例5: bttn_stop
# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import volume [as 别名]
def bttn_stop():
# connect to the Sonos
sonos = SoCo(SONOS_IP)
# connect to Philips Hue Bridge
hue = Bridge(ip=HUE_IP,
username=HUE_USERNAME)
# stop the Sonos and reset to sensible defaults
queue = sonos.get_queue()
sonos.clear_queue()
sonos.volume = STOP_VOLUME
sonos.play_mode = 'NORMAL'
sonos.stop()
# set the lights back to a sensible default
command = {
'transitiontime': (STOP_DIMMER_SECONDS * 10),
'on': True,
'bri': STOP_DIMMER_BRIGHTNESS
}
hue.set_light(STOP_LIGHTS, command)
return jsonify(status="success")
示例6: sonos
# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import volume [as 别名]
def sonos(command, volume=-1):
s = SoCo(app.config['SONOS'])
try:
if command == 'play':
s.play()
elif command == 'pause':
s.pause()
elif command =='volume':
logging.info('Setting volume of Sonos to %d' % volume)
s.volume(volume)
elif command == 'next':
s.next()
elif command == 'previous':
s.previous()
return "OK"
except:
return "FAIL"
示例7: sexy_time
# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import volume [as 别名]
def sexy_time():
# connect to the Sonos
sonos = SoCo(SONOS_IP)
# connect to Philips Hue Bridge
hue = Bridge(ip=HUE_IP,
username=HUE_USERNAME)
# get queue
queue = sonos.get_queue()
# if we:
# * already have a queue
# * music is playing
# * we are already playing a queue that begins with "Let's Get It On"
# ...then skip to the next track
if len(queue) > 0 and \
sonos.get_current_transport_info()['current_transport_state'] == "PLAYING" and \
queue[0].title == SEXY_TIME_FIRST_TRACK:
sonos.next()
# else, intitiate a fresh Sexy Time
else:
# clear Sonos queue
sonos.clear_queue()
# turn off shuffle and repeat
sonos.play_mode = 'NORMAL'
# set volume
sonos.volume = 45
# play Sexy Time playlist
playlist = get_sonos_playlist(sonos, SEXY_TIME_PLAYLIST_NAME)
if playlist:
sonos.add_to_queue(playlist)
sonos.play()
# dim the lights (bri out of 254) over the pre-defined amount of time
command = {
'transitiontime': (SEXY_TIME_DIMMER_SECONDS * 10),
'on': True,
'bri': SEXY_TIME_DIMMER_BRIGHTNESS
}
hue.set_light(1, command)
return jsonify(status="success")
示例8: playTheme
# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import volume [as 别名]
def playTheme(data, cur, themes, sonosPlayer):
if data['hw'] in themes.keys() and getLastAction(data, cur) == 'remove':
from soco import SoCo
sonos = SoCo(sonosPlayer)
if sonos.get_current_transport_info() == 'PLAYING':
return '';
sonos.unjoin();
sonos.play_uri(themes[data['hw']])
sonos.volume = 20;
if sonos.get_current_transport_info() == 'PLAYING':
return '';
sonos.play()
syslog.syslog('Playing theme for: ' + data['hw'])
示例9: callback
# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import volume [as 别名]
def callback(d):
data = json.loads(d)
url = data['url']
sonos_devices = SonosDiscovery()
ips = sonos_devices.get_speaker_ips()
master = SoCo(ips[0])
masteruid = master.get_speaker_info()['uid']
for ip in ips:
if not (ip == master.speaker_ip):
slave = SoCo(ip)
ret = slave.join(masteruid)
oldvol = master.volume
master.volume = 60
master.play_uri(url)
playing = True
while playing:
if master.get_current_transport_info()['current_transport_state'] == 'STOPPED':
playing = False
master.volume = oldvol
for ip in ips:
if not (ip == master.speaker_ip):
slave = SoCo(ip)
slave.unjoin()
示例10: playTheme
# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import volume [as 别名]
def playTheme(themes, sonosPlayer):
sonos = SoCo(sonosPlayer)
#syslog.syslog('%s' % str(sonos.get_current_track_info()))
#return '';
if playerPlays(sonos):
syslog.syslog('Already playing')
return '';
sonos.unjoin()
sonos.clear_queue()
sonos.add_uri_to_queue(themes['closer'])
sonos.play_mode = 'REPEAT_ALL'
syslog.syslog('%s' % sonos.play_mode)
sonos.volume = 5;
if playerPlays(sonos):
return '';
sonos.play()
syslog.syslog('Playing Closer')
示例11: arriving_home
# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import volume [as 别名]
def arriving_home():
# connect to Philips Hue Bridge
hue = Bridge(ip=HUE_IP,
username=HUE_USERNAME)
# set the lights to approximately 80% over 3 seconds
command = {
'transitiontime': 30,
'on': True,
'bri': 203
}
hue.set_light(1, command)
# connect to the Sonos
sonos = SoCo(SONOS_IP)
# clear the queue
sonos.clear_queue()
# set volume
sonos.volume = 25
# play Arriving Home playlist
playlist = get_sonos_playlist(sonos, ARRIVING_HOME_PLAYLIST_NAME)
print playlist
if playlist:
sonos.add_to_queue(playlist)
# turn on shuffle, turn off repeat
sonos.play_mode = 'SHUFFLE_NOREPEAT'
# play
sonos.play()
# we're in shuffle mode, but the first track is always the same
sonos.next()
return jsonify(status="success")
示例12: arriving_home
# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import volume [as 别名]
def arriving_home():
# connect to Philips Hue Bridge
hue = Bridge(ip=HUE_IP,
username=HUE_USERNAME)
# set the lights to appropriate brightness over appropriate time
command = {
'transitiontime': (ARRIVING_HOME_DIMMER_SECONDS * 10),
'on': True,
'bri': ARRIVING_HOME_DIMMER_BRIGHTNESS
}
hue.set_light(ARRIVING_HOME_LIGHTS, command)
# connect to the Sonos
sonos = SoCo(SONOS_IP)
# clear the queue
sonos.clear_queue()
# set volume
sonos.volume = ARRIVING_HOME_VOLUME
# play Arriving Home playlist
playlist = get_sonos_playlist(sonos, ARRIVING_HOME_PLAYLIST_NAME)
if playlist:
sonos.add_to_queue(playlist)
# turn on shuffle, turn off repeat
sonos.play_mode = 'SHUFFLE_NOREPEAT'
# play
sonos.play()
# we're in shuffle mode, but the first track is always the same
sonos.next()
return jsonify(status="success")
示例13: party
# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import volume [as 别名]
def party():
# connect to the Sonos
sonos = SoCo(SONOS_IP)
# get queue
queue = sonos.get_queue()
# if we:
# * already have a queue
# * music is playing
# ...then skip to the next track
if len(queue) > 0 and sonos.get_current_transport_info()['current_transport_state'] == "PLAYING":
sonos.next()
# else, intitiate a fresh Party Time
else:
# clear Sonos queue
sonos.clear_queue()
# turn on shuffle, turn off repeat
sonos.play_mode = 'SHUFFLE_NOREPEAT'
# set volume
sonos.volume = 45
# play Party playlist
playlist = get_sonos_playlist(sonos, PARTY_TIME_PLAYLIST_NAME)
if playlist:
sonos.add_to_queue(playlist)
sonos.play()
return jsonify(status="success")
示例14: adc0
# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import volume [as 别名]
if DEBUG:
print "trim_pot:", trim_pot
print "pot_adjust:", pot_adjust
print "last_read", last_read
if ( pot_adjust > tolerance ):
trim_pot_changed = True
if DEBUG:
print "trim_pot_changed", trim_pot_changed
if ( trim_pot_changed ):
set_volume = trim_pot / 10.24 # convert 10bit adc0 (0-1024) trim pot read into 0-100 volume level
set_volume = round(set_volume) # round out decimal value
set_volume = int(set_volume) # cast volume as integer
print 'Volume = {volume}%' .format(volume = set_volume)
set_vol_cmd = 'sudo amixer cset numid=1 -- {volume}% > /dev/null' .format(volume = set_volume)
sonos.volume = set_volume
#os.system(set_vol_cmd) # set volume
if DEBUG:
print "set_volume", set_volume
print "tri_pot_changed", set_volume
# save the potentiometer reading for the next loop
last_read = trim_pot
# hang out and do nothing for a half second
time.sleep(0.5)
示例15: Song
# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import volume [as 别名]
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)
try:
sonos.next()
except SoCoUPnPException:
print '[{"icon": "font-awesome:times-circle", "title": "Not supported for current playback source."}]'
elif action == 'prev':
# Previous Song (might be unsupported by playback source e.g. streams)
try:
sonos.previous()
except SoCoUPnPException:
print '[{"icon": "font-awesome:times-circle", "title": "Not supported for current playback source."}]'