• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python soco.SoCo类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中soco.SoCo的典型用法代码示例。如果您正苦于以下问题:Python SoCo类的具体用法?Python SoCo怎么用?Python SoCo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了SoCo类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: sonos_play_from_queue

    def sonos_play_from_queue(self):
        """sonos_play_from_queue, speelt queue af
        """
        
        # pagina laden voor als antwoord terug aan de server
        h = queuebeheer_temp.sonos_play_from_queue()

        # queue afspelen als deze niet leeg is
        sonos = SoCo(COORDINATOR)
        if len(sonos.get_queue()) > 0:
            sonos.play_from_queue(0)

        return h
开发者ID:dirk2011,项目名称:mymc_git,代码行数:13,代码来源:queuebeheer.py


示例17: playTheme

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'])
开发者ID:Hexren,项目名称:dhcpThemeSongs,代码行数:13,代码来源:dhcpevent.py


示例18: bttn_stop

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")
开发者ID:andrewladd,项目名称:auto-awesome,代码行数:27,代码来源:server.py


示例19: bttn_stop

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")
开发者ID:mrkipling,项目名称:auto-awesome,代码行数:27,代码来源:server.py


示例20: __init__

class Sonos:
	def __init__(self, ip):
		self.sonos = SoCo(ip)
		self.sonos.volume = 60

	def playJason(self):
		self.sonos.play_uri("x-sonos-spotify:spotify%3atrack%3a6g6A7qNhTfUgOSH7ROOxTD?sid=12&flags=32")
		time.sleep(1)
		self.sonos.pause()

	def randomKatyPerrySong(self):
		darkHorse = 'x-sonos-spotify:spotify%3atrack%3a5jrdCoLpJSvHHorevXBATy?sid=12&flags=32'
		firework = 'x-sonos-spotify:spotify%3atrack%3a4lCv7b86sLynZbXhfScfm2?sid=12&flags=32'
		roar = 'x-sonos-spotify:spotify%3atrack%3a3XSczvk4MRteOw4Yx3lqMU?sid=12&flags=32'
		birthday = 'x-sonos-spotify:spotify%3atrack%3a2xLOMHjkOK8nzxJ4r6yOKR?sid=12&flags=32'
		californiaGurls = 'x-sonos-spotify:spotify%3atrack%3a6tS3XVuOyu10897O3ae7bi?sid=12&flags=32'
		teenageDream = 'x-sonos-spotify:spotify%3atrack%3a55qBw1900pZKfXJ6Q9A2Lc?sid=12&flags=32'
		lastFridayNight	= 'x-sonos-spotify:spotify%3atrack%3a455AfCsOhhLPRc68sE01D8?sid=12&flags=32'
		peacock = 'x-sonos-spotify:spotify%3atrack%3a3y3Hucw52QpjtHUeOKTkaO?sid=12&flags=32'
		et = 'x-sonos-spotify:spotify%3atrack%3a4kkeuVl6gF3RMqE4Nn5W3E?sid=12&flags=32'

		songs = [darkHorse, firework, roar, birthday, californiaGurls, teenageDream, lastFridayNight, peacock, et]
		chosen_song = random.choice(songs)
		return chosen_song

	def playKatyPerry(self):
		self.playJason()
		self.sonos.play_uri(self.randomKatyPerrySong())
		# set Katy Perry duration here (in seconds)
		time.sleep(10)
		self.sonos.pause()
开发者ID:JTFrancis,项目名称:Sonos,代码行数:31,代码来源:sonos.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python generic_app.main函数代码示例发布时间:2022-05-27
下一篇:
Python soco.discover函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap