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


Python SoCo.get_current_transport_info方法代码示例

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


在下文中一共展示了SoCo.get_current_transport_info方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: playTheme

# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import get_current_transport_info [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'])
开发者ID:Hexren,项目名称:dhcpThemeSongs,代码行数:15,代码来源:dhcpevent.py

示例2: now_playing

# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import get_current_transport_info [as 别名]
	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,代码行数:30,代码来源:sonos.py

示例3: Sonos

# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import get_current_transport_info [as 别名]
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,代码行数:32,代码来源:sonos.py

示例4: playpause

# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import get_current_transport_info [as 别名]
	def playpause(self):
		my_zone = SoCo('192.168.1.19')
		status = my_zone.get_current_transport_info()
		if(status['current_transport_state'] == "PLAYING"):
			print('Sonos - Pause')
			my_zone.pause()
		else:
			print('Sonos- Play')
			my_zone.play()
开发者ID:bgriffiths,项目名称:ledsign,代码行数:11,代码来源:sonos.py

示例5: sexy_time

# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import get_current_transport_info [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")
开发者ID:andrewladd,项目名称:auto-awesome,代码行数:55,代码来源:server.py

示例6: say

# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import get_current_transport_info [as 别名]
def say(text):
    ok, file_name =  text2mp3(text, PATH, LANGUAGE)
    if ok:
        zp = SoCo(IP)
        cur_info = zp.get_current_track_info()
        state = zp.get_current_transport_info()
        zp.play_uri("http://{0}:5000/static/speech.mp3".format(LAN_IP))
        if (state['current_transport_state'] == 'PLAYING'):
            audio = MP3("./static/speech.mp3")
            speech_info = zp.get_current_track_info()
            duration = speech_info['duration']
            Timer(audio.info.length, resume_queue, (zp, cur_info)).start()
    return "OK!"
开发者ID:r0stig,项目名称:say,代码行数:15,代码来源:server.py

示例7: callback

# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import get_current_transport_info [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()
开发者ID:sammachin,项目名称:twiliopaging,代码行数:25,代码来源:client.py

示例8: party

# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import get_current_transport_info [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")
开发者ID:andrewladd,项目名称:auto-awesome,代码行数:38,代码来源:server.py

示例9: printlog

# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import get_current_transport_info [as 别名]
needToQuit = False

##list all available hipchat rooms
##and connect to the one specified in config.txt
for room in hipchat.rooms()['items']:
    printlog(room['name'])
    if(room['name'] == hipChatRoomName):
        hipChatRoom = room
printlog('joined room: ' + hipChatRoom['name'])

while not needToQuit:
    try:
        newTrackInfo = zone.get_current_track_info()
##        only procede if the player is playing
        if zone.get_current_transport_info()['current_transport_state'] == 'PLAYING':
##              if the current track exists and is different from the last we found procede
            if(currentTrackInfo == None or newTrackInfo['title'] != currentTrackInfo['title']):
                #format a cool hipchat message containing a search link an album image and the track info
                #put together a google search url
                searchStr = unicode(newTrackInfo['title']) +' ' + unicode(newTrackInfo['artist']) + ' ' +unicode(newTrackInfo['album'])
                searchStr = searchStr.replace(' ','+')
                printlog(searchStr)
                
                noteStr = '<a href="http://www.google.com/search?q='+searchStr + '">'
                #only include the album image if this track has a different album from the last one
                if(currentTrackInfo == None or newTrackInfo['album'] != currentTrackInfo['album']):
                    noteStr += '<img style="float:left; width:50px;height:50px;" src="' + unicode(newTrackInfo['album_art'])+ '">'
                noteStr += '<p >'
                noteStr += '<b>' + unicode(newTrackInfo['title']) + '</b>'
                noteStr += ' - <b>' + unicode(newTrackInfo['artist'])+ '</b>'
开发者ID:BenVanCitters,项目名称:Sonos-HipChat,代码行数:32,代码来源:roomSonos.py

示例10: SoCo

# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import get_current_transport_info [as 别名]
			sys.exit()
	
	# init sonos
	directory_path = os.path.expanduser(dropbox_path)
	sonos = SoCo(sonos_ip) 
	sonos.volume = sonos_volume
	state = ''
	
	# check if we should stop the plaver
	if argument == '-s':
		sonos.stop();
		sys.exit()
	
	# enter main loop
	while True:
		state = sonos.get_current_transport_info()['current_transport_state']
		
		if state  == 'PLAYING':
			print 'Playing song. Waiting for it to finish...'
		else:			
			print 'checking for files...'
		
			# get files from directory
			file_list = [f for f in listdir(directory_path) if isfile(join(directory_path, f))]
		
			# pick the first file that starts with file_prefix
			song_id = ""
			if len(file_list) > 0:
				for file in file_list:
					if file.startswith(file_prefix):
						full_filepath = directory_path + '/' + file
开发者ID:pstigenberg,项目名称:SonosLab,代码行数:33,代码来源:sonos.py

示例11: __init__

# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import get_current_transport_info [as 别名]

#.........这里部分代码省略.........
            except:
                return
            self.sonos.play_from_queue(queue_pos)
            self.sonos.seek(self.track_info_to_return_to["position"])
        if self.state_info_to_return_to["current_transport_state"] == "PAUSED_PLAYBACK" or self.state_info_to_return_to["current_transport_state"] == "STOPPED":
            self.changeState(SONOS_RESTORE_PEND)
            self.time_out = 3
            self.retry_count = 2
        else:
            self.completed()

    def abort(self):
        self.logState("Aborting")
        self.play_pending = False
        self.abort_pending = True
        self.restore()

    def completed(self):
        if self.abort_pending:
            self.logState("Finished - ABORTED")
        else:
            self.logState("Finished - OK")
        self.play_pending = False
        self.abort_pending = False
        self.changeState(SONOS_IDLE)

    def logState(self, info):
        if self.state_var == SONOS_IDLE:
            if self.logged_idle:
                return
            self.logged_idle = True
        else:
            self.logged_idle = False
        transp_info = self.sonos.get_current_transport_info()
        track_info = self.sonos.get_current_track_info()
        print ("StateNow: ", self.state_var, " PrevState", self.prev_state, " TimeOut: ", self.time_out, " Elapsed: ", self.elapsedTime(), "RetryCount: ", self.retry_count, " TranspState: ", transp_info["current_transport_state"], " PlaylistPos: ", track_info["playlist_position"], "Info: ", info)

    def handleState(self):
        # Handle idle
        if self.state_var == SONOS_IDLE:
            if self.play_pending:
                self.changeState(SONOS_PLAY_REQ)
            return
        # Get current state information from sonos unit
        transp_info = self.sonos.get_current_transport_info()
        track_info = self.sonos.get_current_track_info()
        cur_transp_state = transp_info['current_transport_state']
        self.logState("handleStateEntry")
        # Handle other states
        if self.state_var == SONOS_PLAY_REQ:
            self.vol_to_return_to = self.sonos.volume
            self.track_info_to_return_to = track_info
            self.state_info_to_return_to = transp_info
            self.retry_count = 2
            self.changeState(SONOS_PAUSE_TRY)
        elif self.state_var == SONOS_PAUSE_TRY:
            self.time_out = 10
            if cur_transp_state == "PLAYING":
                self.sonos.pause()
            self.changeState(SONOS_PAUSE_PEND)
        elif self.state_var == SONOS_PAUSE_PEND:
            if cur_transp_state == "PAUSED_PLAYBACK" or cur_transp_state == "STOPPED":
                self.changeState(SONOS_PLAY_START)
            elif cur_transp_state == "PLAYING":
                if self.elapsedTime() > self.time_out:
                    self.retry_count -= 1
开发者ID:robdobsn,项目名称:RdHomeServer,代码行数:70,代码来源:SonosDevice.py


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