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


Python SoCo.stop方法代码示例

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


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

示例1: bttn_stop

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

示例2: bttn_stop

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

示例3: SoCo

# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import stop [as 别名]
if __name__ == '__main__':
    if (len(sys.argv) != 3):
        print "Usage: sonoshell.py [speaker's IP] [cmd]"
        print ""
        print "Valid commands: play, pause, stop, next, previous, current, and partymode"
        sys.exit()

    speaker_ip = sys.argv[1]
    cmd = sys.argv[2].lower()

    sonos = SoCo(speaker_ip)

    if (cmd == 'partymode'):
        print sonos.partymode()
    elif (cmd == 'play'):
        print sonos.play()
    elif (cmd == 'pause'):
        print sonos.pause()
    elif (cmd == 'stop'):
        print sonos.stop()
    elif (cmd == 'next'):
        print sonos.next()
    elif (cmd == 'previous'):
        print sonos.previous()
    elif (cmd == 'current'):
        track = sonos.get_current_track_info()

        print 'Current track: ' + track['artist'] + ' - ' + track['title'] + '. From album ' + track['album'] + '. This is track number ' + track['playlist_position'] + ' in the playlist. It is ' + track['duration'] + ' minutes long.'
    else:
        print "Valid commands: play, pause, stop, next, previous, current, and partymode"
开发者ID:DonGar,项目名称:SoCo,代码行数:32,代码来源:sonoshell.py

示例4: main

# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import stop [as 别名]
import re
from settings import *
from soco import SonosDiscovery, SoCo
import speaker_info

def main():
	si = {}
	try:
		si = speaker_info.load_speaker_info()
	except Exception, e:
		speaker_info.refresh_speaker_info()
		si = speaker_info.load_speaker_info()	
	
	for (ip, speaker) in si.items():
		if re.search(PRIMARY_ZONE, speaker.get('zone_name', ''), re.I) is not None:
			s = SoCo(ip)
			s.volume(speaker_info.recall_volume(ip))
			s.stop()

if __name__ == '__main__':
	main()
开发者ID:sbma44,项目名称:shairport,代码行数:23,代码来源:disengage.py

示例5: SoCo

# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import stop [as 别名]
	# check if discovery mode
	if argument == '-d':
		for sonos_players in soco.discover():
			print sonos_players.player_name
			print sonos_players.ip_address
			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
开发者ID:pstigenberg,项目名称:SonosLab,代码行数:33,代码来源:sonos.py

示例6: __init__

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

    def __init__(self, sonos_ip):
        self.state_var = SONOS_IDLE
        self.sonos_ip = sonos_ip
        self.sonos = SoCo(self.sonos_ip)
        self.vol_to_return_to = self.sonos.volume
        self.time_out = 0
        self.retry_count = 0
        self.state_entry_time = time.time()
        self.prev_state = SONOS_IDLE
        self.logged_idle = False
        self.sound_uri = ""
        self.play_pending = False
        self.abort_pending = False
        self.play_volume = 30
        self.track_info_to_return_to = None
        self.state_info_to_return_to = None

    def execCmd(self, cmd, param, meta):
        self.state_var = SONOS_IDLE
        self.play_pending = False
        self.abort_pending = False
        if cmd.lower() == "play":
            if param == "":
                self.sonos.play()
            else:
                self.sonos.play_uri(param, meta)
        elif cmd.lower() == "stop":
            self.sonos.stop()
        elif cmd.lower() == "volup":
            self.sonos.volume = self.sonos.volume + 10
        elif cmd.lower() == "voldown":
            self.sonos.volume = self.sonos.volume - 10

    def musicStop(self):
        self.state_var = SONOS_IDLE
        self.play_pending = False
        self.abort_pending = False
        self.sonos.stop()

    def getDeviceName(self):
        return self.sonos.player_name

    def getFavouriteRadioStations(self):
        return self.sonos.get_favorite_radio_stations(0,6)

    def playSound(self, soundUri, playVolume):
        self.sound_uri = soundUri
        self.play_volume = playVolume
        self.play_pending = True

    def elapsedTime(self):
        return time.time() - self.state_entry_time

    def changeState(self, newState):
        self.prev_state = self.state_var
        self.state_var = newState
        self.state_entry_time = time.time()

    def restore(self):
        self.sonos.volume = self.vol_to_return_to
        # Check for radio or similar
        # Currently this is done by checking the track duration
        if self.track_info_to_return_to["duration"] == "0:00:00":
            # Handle playing from the radio or similar
            self.sonos.play_uri(self.track_info_to_return_to["uri"])
        else:
            # Handle continuation of playing a track from the queue
            try:
                queue_pos = int(self.track_info_to_return_to["playlist_position"]) - 1
            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:
#.........这里部分代码省略.........
开发者ID:robdobsn,项目名称:RdHomeServer,代码行数:103,代码来源:SonosDevice.py


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