本文整理汇总了Python中soco.SoCo类的典型用法代码示例。如果您正苦于以下问题:Python SoCo类的具体用法?Python SoCo怎么用?Python SoCo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SoCo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: now_playing
def now_playing(self):
my_zone = SoCo('192.168.86.225')
status = my_zone.get_current_transport_info()
track = my_zone.get_current_track_info()
artist = ''
title = ''
if(track['artist'] == '' and track['title'] == ''):
return "Stopped - Playlist Empty"
elif (track['artist'] == '' and track['title'] != ''):
title = track['title']
parts = title.split('|')
for part in parts:
if(part[:7] == 'ARTIST '):
artist = part[7:]
elif(part[:6] == 'TITLE '):
title = part[6:]
else:
artist = track['artist']
title = track['title']
state = "Now Playing: "
if(status['current_transport_state'] == 'STOPPED'):
state = "Up Next"
return state + artist + ' - ' + title
示例2: Sonos
class Sonos(AbstractJob):
def __init__(self, conf):
self.interval = conf['interval']
self.sonos = SoCo(conf['ip'])
def get(self):
zone_name = self.sonos.get_speaker_info()['zone_name']
np = self.sonos.get_current_track_info()
current_track = np if np['playlist_position'] != '0' else None
queue = self.sonos.get_queue(int(np['playlist_position']), 1)
next_item = queue.pop() if len(queue) > 0 else None
next_track = {}
if next_item is not None:
next_track = {
'artist': next_item.creator,
'title': next_item.title,
'album': next_item.album
}
state = self.sonos.get_current_transport_info()[
'current_transport_state']
return {
'room': zone_name,
'state': state,
'current': current_track,
'next': next_track
}
示例3: GET
def GET(self, ipadress):
web.header('Content-Type', 'application/json')
web.header('Access-Control-Allow-Origin', '*')
web.header('Access-Control-Allow-Credentials', 'true')
sonos = SoCo(ipadress)
track = sonos.get_current_track_info()
return json.dumps(track)
示例4: volume_down
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
示例5: GET
def GET(self):
web.header('Access-Control-Allow-Origin', '*')
web.header('Access-Control-Allow-Credentials', 'true')
data = web.input(uri="no", player="no")
sonos = SoCo('192.168.1.105')
sonos.play_uri(data.uri)
track = sonos.get_current_track_info()
return track['title'] + " - " + data.player
示例6: stopPlaying
def stopPlaying(self):
for speakerIp in self.sonos.get_speaker_ips():
sonosSpeaker = SoCo(speakerIp)
all_info = sonosSpeaker.get_speaker_info()
for item in all_info:
logging.info("Stopping for speaker %s: %s" % (item, all_info[item]))
sonos.stop()
LCDScreen.updateStatus("Sonos" , "Music Stopped" )
示例7: refresh_speaker_info
def refresh_speaker_info():
sd = SonosDiscovery()
possible_matches = sd.get_speaker_ips()
speaker_info = {}
for ip in possible_matches:
s = SoCo(ip)
try:
speaker_info[ip] = s.get_speaker_info()
except Exception, e:
speaker_info[ip] = {}
示例8: play
def play(self):
self.logger.info('Playing zones...')
for ip in self._ZONE_IPS:
device = SoCo(ip)
self.logger.debug('Playing zone at %s', ip)
if not device.play():
self.logger.error('Unable to play zone at %s', ip)
return False
self.logger.info('All zones playing.')
return True
示例9: pause
def pause(self):
self.logger.info('Pausing zones...')
for ip in self._ZONE_IPS:
device = SoCo(ip)
self.logger.debug('Pausing zone at %s', ip)
if not device.pause():
self.logger.error('Unable to pause zone at %s', ip)
return False
self.logger.info('All zones paused.')
return True
示例10: listAll
def listAll(self):
for speakerIp in self.sonos.get_speaker_ips():
logging.info("********* %s ***********" % str(speakerIp))
sonosSpeaker = SoCo(speakerIp)
all_info = sonosSpeaker.get_speaker_info()
for item in all_info:
logging.info(" %s: %s" % (item, all_info[item]))
logging.info('co-ordinator = ' + str(sonosSpeaker.get_group_coordinator(all_info['zone_name'], True)))
logging.info("****************************" )
示例11: main
def main():
with closing(MySQLdb.connect(
login.DB_HOST, login.DB_USER,
login.DB_PASSWORD, login.DB_DATABASE)) as connection:
with closing(connection.cursor()) as cursor:
cursor.execute('SELECT ip FROM sonos WHERE id="1"')
ip = cursor.fetchone()[0]
sonos = SoCo(ip)
sonos.start_library_update()
示例12: sonos_pause
def sonos_pause(self):
"""Afspeellijst, <pause> button, afspelen pauzeren.
"""
# pagina laden voor als antwoord terug aan de server
h = queuebeheer_temp.sonos_pause()
## sonos, afspelen pauzeren
sonos = SoCo(COORDINATOR)
sonos.pause()
return h
示例13: sonos_previous
def sonos_previous(self):
"""Afspeellijst, <Previous> button, gaat naar vorige nummer, in de afspeellijst.
"""
# pagina laden voor als antwoord terug aan de server
h = queuebeheer_temp.sonos_previous()
##
sonos = SoCo(COORDINATOR)
sonos.previous()
return h
示例14: sonos_next
def sonos_next(self):
"""Afspeellijst <Next> button, gaat naar volgende nummer in afspeellijst.
"""
# pagina laden voor als antwoord terug aan de server
h = queuebeheer_temp.sonos_next()
##
sonos = SoCo(COORDINATOR)
sonos.next()
return h
示例15: sonos_play
def sonos_play(self):
"""Afspeellijst, <play> button, afspelen of doorgaan na een pauze.
"""
# pagina laden voor als antwoord terug aan de server
h = queuebeheer_temp.sonos_play()
## sonos, afspelen
sonos = SoCo(COORDINATOR)
sonos.play()
return h