当前位置: 首页>>代码示例>>Python>>正文


Python soco.SoCo类代码示例

本文整理汇总了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
开发者ID:bgriffiths,项目名称:ledsign,代码行数:28,代码来源:sonos.py

示例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
        }
开发者ID:COLABORATI,项目名称:jarvis2,代码行数:30,代码来源:sonos.py

示例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)
开发者ID:oyvindmal,项目名称:DigitalHomeWebApi,代码行数:9,代码来源:code.py

示例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
开发者ID:Cushychicken,项目名称:Sonos-Clock,代码行数:9,代码来源:clock.py

示例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
开发者ID:oyvindmal,项目名称:SocoWebService,代码行数:9,代码来源:WebService.py

示例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" )
开发者ID:rustycoopes,项目名称:projects,代码行数:9,代码来源:sonos_pandora.py

示例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] = {}
开发者ID:sbma44,项目名称:shairport,代码行数:10,代码来源:speaker_info.py

示例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
开发者ID:Cushychicken,项目名称:blockclock,代码行数:10,代码来源:blockclock.py

示例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
开发者ID:Cushychicken,项目名称:blockclock,代码行数:10,代码来源:blockclock.py

示例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("****************************" )
开发者ID:rustycoopes,项目名称:projects,代码行数:10,代码来源:sonos_pandora.py

示例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()
开发者ID:Terminal-Geek,项目名称:dreamberry,代码行数:11,代码来源:sonos.py

示例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
开发者ID:dirk2011,项目名称:mymc_git,代码行数:12,代码来源:queuebeheer.py

示例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
开发者ID:dirk2011,项目名称:mymc_git,代码行数:12,代码来源:queuebeheer.py

示例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
开发者ID:dirk2011,项目名称:mymc_git,代码行数:12,代码来源:queuebeheer.py

示例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
开发者ID:dirk2011,项目名称:mymc_git,代码行数:12,代码来源:queuebeheer.py


注:本文中的soco.SoCo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。