本文整理汇总了Python中soco.SoCo.play_from_queue方法的典型用法代码示例。如果您正苦于以下问题:Python SoCo.play_from_queue方法的具体用法?Python SoCo.play_from_queue怎么用?Python SoCo.play_from_queue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类soco.SoCo
的用法示例。
在下文中一共展示了SoCo.play_from_queue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: sonos_play_from_queue
# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import play_from_queue [as 别名]
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
示例2: __init__
# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import play_from_queue [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:
#.........这里部分代码省略.........