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


Python MPDClient.load方法代码示例

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


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

示例1: __init__

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import load [as 别名]
class Player:
	def __init__(self):
	    self.client = MPDClient()
	    self.client.connect("localhost", 6600)
	    self.client.timeout = 10
	    self.client.idletimeout = None 


	def quit(self):
	    self.client.close()
	    self.client.disconnect()

	def get_playlists(self):
	    val = self.client.listplaylists()
	    return val

	def get_playing(self):
		name = "unknown"
		val = self.client.playlistinfo()
		if(len(val)>0):
			print val[0]
			name = val[0]["name"]

		return name

	def load(self,list):
		print "loading list", list
		self.client.clear()
		self.client.load(list)

	def play(self):
		self.client.play()

	def stop(self):
		self.client.stop()
开发者ID:KarlNewark,项目名称:pyPlaylist,代码行数:37,代码来源:mpc.py

示例2: main

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import load [as 别名]
def main():
    parser = argparse.ArgumentParser(description='wake up with music')
    parser.add_argument('--playlist',
        type=str, help='foo help', default="Alarm Clock")
    parser.add_argument('--sleep',
        type=str, help='foo help', default="90 min")
    args = parser.parse_args()


    r = rxv.RXV("192.168.1.116")
    r.on = True
    time.sleep(0.5)
    r.sleep = args.sleep
    r.input = "HDMI4"
    r.volume = START_VOLUME

    cli = MPDClient()
    cli.connect("dom.wuub.net", 6600)
    cli.clear()
    cli.load(args.playlist)
    cli.play()

    for vol in range(START_VOLUME, MID_VOLUME, 1):
        r.volume = vol
        time.sleep(0.5)

    time.sleep(30)
    requests.get("http://dom.wuub.net/api/lights/small/on")

    for vol in range(MID_VOLUME, TARGET_VOLUME, 1):
        r.volume = vol
        time.sleep(2)

    time.sleep(60)
    requests.get("http://dom.wuub.net/api/lights/large/on")
开发者ID:omy09,项目名称:homeautomation,代码行数:37,代码来源:alarm_clock.py

示例3: play_playlist

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import load [as 别名]
def play_playlist(name):
    client=MPDClient()
    mopidyAddress = 'localhost'
    mopidyPort = 6600

    client.timeout = 10
    client.idletimeout = None
    client.connect(mopidyAddress,mopidyPort)
    #client.password('IlPits2013')
    client.clear()
    if playlist_exists(name):
        client.load(name)
    spotify_lists = get_spotify_playlists()
    name = name.encode('utf-8')
    print name
    #print spotify_lists
    if name in spotify_lists:
        add_spotify_directory(name)
    #time.sleep(1)
    if name == 'Pierre':
        client.shuffle()

    #client.setvol(50)
    #client.play()
    client.disconnect()
    return
开发者ID:NilsNoreyson,项目名称:phoneBookServer,代码行数:28,代码来源:get_phonebook_files.py

示例4: Jukebox

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import load [as 别名]
class Jukebox():
  def __init__(self):
    self.dt = DisplayThread(self)
    self.dt.start()

    ## MPD object instance
    self.client = MPDClient()
    if mpdConnect(self.client, CON_ID):
        print 'Got connected!'
    else:
        print 'fail to connect MPD server.'
        sys.exit(1)
    try:
        f = open('/media/usb/playlist.txt','r')
        playlist = f.readline().rstrip()
        print "Loading " + playlist
        self.client.clear()
        self.client.load(playlist)
    except IOError:
        print "Problem reading playlist"
    self.client.stop()
    self.client.play()

    carryOn = True
    while (carryOn):
        if (humble.switch(0)):
            time.sleep(PAUSE)
            self.toggle()
        if (humble.switch(1)):
            time.sleep(PAUSE)
            self.skip()
        if (humble.switch(2)):
            time.sleep(PAUSE)
            self.stop()
            carryOn = False
            time.sleep(PAUSE)
    # Stop the display thread
    self.dt.done()
    

  def skip(self):
      print "Skipping"
      self.client.next()

  def stop(self):
      print "Stopping"
      self.client.stop()
      humble.data.setLine(0,"")
      humble.data.setLine(1,"")
      humble.data.setLed('red', False)
      humble.data.setLed('green', False)
      time.sleep(0.5)

  def toggle(self):
      status = self.client.status()
      if status['state'] == 'pause' or status['state'] == 'stop':
          self.client.play()
      else:
          self.client.pause()
开发者ID:Cribstone,项目名称:raspberrypi,代码行数:61,代码来源:jukebox.py

示例5: __init__

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import load [as 别名]
class Player:
	def __init__(self):
	    self.client = MPDClient()
	    self.client.connect("localhost", 6600)
	    self.client.timeout = 10
	    self.client.idletimeout = None


	def quit(self):
	    self.client.close()
	    self.client.disconnect()

	def get_playlists(self):
	    val = self.client.listplaylists()
	    return val

	def get_stats(self):
		#{'playtime': '848', 'uptime': '2565'}
		#{'songid': '33', 'playlistlength': '1', 'playlist': '86', 'repeat': '0',
		#'consume': '0', 'mixrampdb': '0.000000', 'random': '0', 'state': 'play',
		# 'elapsed': '7.476', 'volume': '-1', 'single': '0', 'time': '7:0', 'song': '0', 'audio': '44100:16:2', 'bitrate': '128'}
		all = {}
		all.update(self.client.stats())
		all.update(self.client.status())

		stats = {}
		stats["elapsed"] = all["elapsed"] if all.has_key("elapsed") else "0"
		stats["state"] = all["state"] if all.has_key("state") else "stopped"
		stats["playtime"] = all["playtime"]
		stats["uptime"] = all["uptime"]
		stats["bitrate"] = all["bitrate"] if all.has_key('bitrate') else 0
		stats["playlistlength"] = all["playlistlength"] if all.has_key("playlistlength") else 0
		stats["song"] = all["song"] if all.has_key("song") else 0
		# print stats
		return stats

	def get_playing(self):
		name = "unknown"
		val = self.client.currentsong()
		name= val["name"] if val.has_key('name') else None
		name= val["title"] if val.has_key('title') else name
		# print val
		return name

	def load(self, list):
		# print "loading list", list
		self.client.clear()
		self.client.load(list)

	def next(self):
		self.client.next()
	def prev(self):
		self.client.previous()

	def play(self):
		self.client.play()

	def stop(self):
		self.client.stop()
开发者ID:alexellis,项目名称:pyPlaylist,代码行数:61,代码来源:mpc.py

示例6: schedule_playlist

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import load [as 别名]
def schedule_playlist(playlist_name):
    client = MPDClient()
    client.connect(settings.MPD_SERVER, settings.MPD_PORT)
    client.clear()
    client.load(playlist_name)
    client.play(1)
    client.close()
    client.disconnect()
开发者ID:Horrendus,项目名称:radiocontrol,代码行数:10,代码来源:tasks.py

示例7: __init__

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import load [as 别名]
class mpd_client:
    def __init__(self):
        self.client = MPDClient()
        self.connect()

    def connect(self):
        self.client.timeout = None
        self.client.idletimeout = None
        self.client.connect("192.168.1.153", 6600)

    def playing(self):
        if self.client.status()["state"] == "play":
            return True
        else:
            return False

    def stop(self):
        self.client.stop()
        self.client.clear()
        self.client.random(0)

    def instant(self):
        self.client.clear()
        self.client.load("AlarmPlaylist")
        self.client.random(1)
        self.client.play()

    def mpd_command(self, command):
        client = self.client
        dict = {
            "play": client.play,
            "pause": client.pause,
            "stop": self.stop,
            "next": client.next,
            "previous": client.previous,
            "instant": self.instant,
        }
        try:
            if command not in ["vol up", "vol down"]:
                dict[command]()
            elif command == "vol up":
                vol = int(client.status()["volume"])
                if vol != -1 and vol < 99:
                    client.setvol(vol + 2)
                elif vol != -1:
                    client.setvol(100)
            elif command == "vol down":
                vol = int(client.status()["volume"])
                if vol != -1 and vol > 1:
                    client.setvol(vol - 2)
                elif vol != -1:
                    client.setvol(0)
        except "ConnectionError":
            client.connect("localhost", 6600)
            dict[command]()
开发者ID:Giannie,项目名称:Pi_Time,代码行数:57,代码来源:mpd_lib.py

示例8: init

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import load [as 别名]
def init(host="localhost", port=6600, playlist="radio", columns=200):
    global mpd_client
    global mpd_host
    global mpd_port
    global diplay_columns
    mpd_host = host
    mpd_port = port
    diplay_columns = columns
    mpd_client = MPDClient()
    mpd_client.timeout = 20
    mpd_client.idletimeout = None
    mpd_client.connect(mpd_host, mpd_port)
    mpd_client.clear()
    mpd_client.load(playlist)
    mpd_client.play(0)
    mpd_client.disconnect()
开发者ID:thk4711,项目名称:raspiradio,代码行数:18,代码来源:libmpdfunctions.py

示例9: add_stream

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import load [as 别名]
def add_stream(stream_info):
    '''Add stream'''

    if stream_info.get('formats'):
        formats = [(f.get('format_id'), f.get('url')) for f in stream_info['formats'] if f.get('format_id') in ALLOWED_FORMATS]
        formats_dict = dict(formats)
        available_formats = formats_dict.keys()
        for allowed_format in ALLOWED_FORMATS:
            if allowed_format in available_formats:
                stream_url = formats_dict[allowed_format]
                break
    else:
        stream_url = stream_info.get('url')

    if stream_url is None:
        #start_response('500 Internal Server Error', [('Content-type', 'application/json')])
        #return [json.dumps({'status': 'error', 'text': "No URL can be found"})]
        return

    title = stream_info.get('title', 'Youtube stream')
    pls_dict = {
        'title': title,
        'url': stream_url
    }

    pls_text = u'''[playlist]
NumberOfEntries=1
File1=%(url)s
Title1=%(title)s
Length1=-1
version=2''' % pls_dict

    with tempfile.NamedTemporaryFile(suffix='.pls', dir=MPD_PLAYLISTS, delete=False) as pls:
        chmod(pls.name, S_IRGRP | S_IROTH | S_IRUSR | S_IWUSR)
        pls.write(encode(pls_text))
        pls.flush()
        pls_name = basename(pls.name)
        mpdc = MPDClient()
        mpdc.connect(MPD_HOST, 6600)
        mpdc.load(pls_name)
        mpdc.close()


    return [json.dumps({'status': 'success', 'text': pls_text})]
开发者ID:hrubi,项目名称:ytmpd,代码行数:46,代码来源:mpd_add_youtube.py

示例10: play

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import load [as 别名]
def play(playlist):
    client = MPDClient()
    client.connect('localhost', 6600)

    if playlist:
        try:
            client.listplaylistinfo(playlist)
            client.clear()
            client.load(playlist)
            client.play()
        except CommandError as exc_info:
            LOGGER.error('Could not load playlist', exc_info)
            client.disconnect()
            return False
    else:
        LOGGER.warn('No playlist specified, using current playlist')
        client.play()
    client.disconnect()
    return True
开发者ID:Dinoshauer,项目名称:raspberry-alarm,代码行数:21,代码来源:alarm-clock.py

示例11: setText

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import load [as 别名]
             subMenu += 1
             if subMenu > MAX_MENU:
                 subMenu = 0
 
 # select menu or submenu item, or turn backlight on/off        
 if button == 2:
     if buzzing:
         buzzing = False
     elif subMenuSelected:
         if subMenu == RADIO_MENU:
             if playlists != None:
                 try:
                     setText("clear")
                     mpc.clear()
                     setText("load")
                     mpc.load(playlists[playlist]['playlist'])
                     setText("play")
                     mpc.play()
                     playing = True
                 except:
                     e = sys.exc_info()[0]
                     print "Exception in play ", e
             display = RADIO_DISPLAY
         elif subMenu == VOLUME_MENU:
             mpc.setvol(volume*10)
             display = RADIO_DISPLAY
         elif subMenu == ALARM_MENU:
             alarmSet = True
             display = ALARM_DISPLAY
             timeNow = datetime.now()
             alarmDay =  (hours > timeNow.hour or (hours == timeNow.hour and minutes > timeNow.minute))              
开发者ID:lawrie,项目名称:PythonControl,代码行数:33,代码来源:radio.py

示例12: MPDClient

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import load [as 别名]
from mpd import MPDClient

mop = MPDClient()
mop.connect( "localhost" , 6600 )

playlists = map( lambda pl: pl[ "playlist" ], mop.listplaylists() )

mop.load( playlists[ 0 ] )
mop.play( 0 )
开发者ID:prayerslayer,项目名称:radio,代码行数:11,代码来源:mopi.py

示例13: MPDClient

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import load [as 别名]
from time import sleep
import re

client = MPDClient()   
client.timeout = 10 
client.idletimeout = None
client.connect("localhost", 6600)
print(client.mpd_version)

liste = client.listplaylists()

for i in liste:
    print(i['playlist'])

client.clear()
client.load(liste[2]['playlist'])
client.play()
  
  
print (liste[2])


try:
    while 1:
        sleep(1)
except KeyboardInterrupt:
    client.pause(1)
    client.close()                    
    client.disconnect()
    
  
开发者ID:TheIdenty,项目名称:Pi-radio,代码行数:31,代码来源:mpd_test.py

示例14: sleep

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import load [as 别名]
print "Pi 2 Uno connection establishing..."

# connect to arduino uno
uno = serial.Serial( "/dev/ttyACM0", 9600, timeout=1 )

# wait 18 sec
sleep( 18 )

# connect to mpd
mop = MPDClient()
mop.connect( "localhost", 6600 ) # default port

# play first playlist
currentPlaylist = 0
playlists = map( lambda pl: pl[ "playlist" ], mop.listplaylists() )
mop.load( playlists[ currentPlaylist] )

# tell arduino we're ready
uno.write( "CMD RUN\n\r" )

sleep( 12 )
mop.play( 0 )

# ==== FUNCTIONS ====

def processCommand( input ):
	# if command doesn't start with CMD return
	if not( input.startswith( "CMD" ) ):
		return
	# check if it's SET VOLUME
	if input.startswith( "CMD SET VOLUME" ):
开发者ID:prayerslayer,项目名称:radio,代码行数:33,代码来源:pi2uno.py


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