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


Python SoCo.play_mode方法代码示例

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


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

示例1: bttn_stop

# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import play_mode [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 play_mode [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: sexy_time

# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import play_mode [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

示例4: playTheme

# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import play_mode [as 别名]
def playTheme(themes, sonosPlayer):
    sonos = SoCo(sonosPlayer)
    #syslog.syslog('%s' % str(sonos.get_current_track_info()))
    #return '';
    if playerPlays(sonos):
        syslog.syslog('Already playing')
        return '';
    sonos.unjoin()
    sonos.clear_queue()
    sonos.add_uri_to_queue(themes['closer'])
    sonos.play_mode = 'REPEAT_ALL'
    syslog.syslog('%s' % sonos.play_mode)
    sonos.volume = 5;    
    if playerPlays(sonos):
        return '';    
    sonos.play()
    syslog.syslog('Playing Closer')
开发者ID:Hexren,项目名称:dhcpThemeSongs,代码行数:19,代码来源:playCloser.py

示例5: arriving_home

# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import play_mode [as 别名]
def arriving_home():
    # connect to Philips Hue Bridge
    hue = Bridge(ip=HUE_IP,
                 username=HUE_USERNAME)

    # set the lights to approximately 80% over 3 seconds

    command = {
        'transitiontime': 30,
        'on': True,
        'bri': 203
    }

    hue.set_light(1, command)

    # connect to the Sonos
    sonos = SoCo(SONOS_IP)

    # clear the queue
    sonos.clear_queue()

    # set volume
    sonos.volume = 25

    # play Arriving Home playlist

    playlist = get_sonos_playlist(sonos, ARRIVING_HOME_PLAYLIST_NAME)
    print playlist

    if playlist:
        sonos.add_to_queue(playlist)

        # turn on shuffle, turn off repeat
        sonos.play_mode = 'SHUFFLE_NOREPEAT'

        # play
        sonos.play()

        # we're in shuffle mode, but the first track is always the same
        sonos.next()

    return jsonify(status="success")
开发者ID:andrewladd,项目名称:auto-awesome,代码行数:44,代码来源:server.py

示例6: arriving_home

# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import play_mode [as 别名]
def arriving_home():
    # connect to Philips Hue Bridge
    hue = Bridge(ip=HUE_IP,
                 username=HUE_USERNAME)

    # set the lights to appropriate brightness over appropriate time

    command = {
        'transitiontime': (ARRIVING_HOME_DIMMER_SECONDS * 10),
        'on': True,
        'bri': ARRIVING_HOME_DIMMER_BRIGHTNESS
    }

    hue.set_light(ARRIVING_HOME_LIGHTS, command)

    # connect to the Sonos
    sonos = SoCo(SONOS_IP)

    # clear the queue
    sonos.clear_queue()

    # set volume
    sonos.volume = ARRIVING_HOME_VOLUME

    # play Arriving Home playlist
    playlist = get_sonos_playlist(sonos, ARRIVING_HOME_PLAYLIST_NAME)

    if playlist:
        sonos.add_to_queue(playlist)

        # turn on shuffle, turn off repeat
        sonos.play_mode = 'SHUFFLE_NOREPEAT'

        # play
        sonos.play()

        # we're in shuffle mode, but the first track is always the same
        sonos.next()

    return jsonify(status="success")
开发者ID:mrkipling,项目名称:auto-awesome,代码行数:42,代码来源:server.py

示例7: party

# 需要导入模块: from soco import SoCo [as 别名]
# 或者: from soco.SoCo import play_mode [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


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