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


Python MPDClient.listplaylists方法代码示例

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


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

示例1: __init__

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import listplaylists [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: __init__

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

示例3: __init__

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import listplaylists [as 别名]
 def __init__(self, **kwargs):
     c = MPDClient()
     c.connect('localhost', 6600)
     
     menu_items = \
         [self.itm('All artists', True, None)] + \
         [self.itm(a['playlist'], True, None) for a in c.listplaylists()]
     
     super().__init__(title="Browsing artists", menu_items=menu_items, **kwargs)
开发者ID:elliotnunn,项目名称:bling,代码行数:11,代码来源:mpdbrowser.py

示例4: playlist_exists

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

    client.timeout = 10
    client.idletimeout = None
    client.connect(mopidyAddress,mopidyPort)
    #client.password('IlPits2013')

    playlists = client.listplaylists()

    p_names = [p['playlist'] for p in playlists]

    client.disconnect()
    return name in p_names
开发者ID:NilsNoreyson,项目名称:phoneBookServer,代码行数:18,代码来源:get_phonebook_files.py

示例5: MPDClient

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import listplaylists [as 别名]
client.loop_start()

try:
	client.connect("192.168.0.101", 1883, 60)
	
except socket.error:
	print "Failed to connect to mqtt"	

while True:
    try:
	    mpc = MPDClient()
	    mpc.timeout = 10

	    mpc.connect("localhost", 6600)
	    mpc.setvol(volume*10)
	    playlists = mpc.listplaylists()
	    print playlists
	    break
    except socket.error:
	    print "Failed to connect to mpd"
	    setText("mpc failure")
	    button = 0
	    while not button:
	        button = read_buttons()
	    setText("Retrying ...")  

# Main loop
while True:
    try:
        # Process buttons
        button = read_buttons()
开发者ID:lawrie,项目名称:PythonControl,代码行数:33,代码来源:radio.py

示例6: MPDClient

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import listplaylists [as 别名]
#!/usr/bin/python

from mpd import MPDClient
client = MPDClient()               # create client object
client.timeout = 10                # network timeout in seconds (floats allowed), default: None
client.idletimeout = None          # timeout for fetching the result of the idle command is handled seperately, default: None
client.connect("bluesnogbox.duckdns.org", 6600)  # connect to URL:6600 (default port)

print(client.mpd_version)          # print the MPD version
print(client.listplaylists())

client.close()                     # send the close command
client.disconnect()                # disconnect from the server
开发者ID:bluesnogbox,项目名称:mpd-bot,代码行数:15,代码来源:init.py

示例7: MPDClient

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

示例8: MPDClient

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import listplaylists [as 别名]
import RPi.GPIO as GPIO
from mpd import MPDClient
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,代码行数:33,代码来源:mpd_test.py

示例9: main

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import listplaylists [as 别名]
def main():

    ## MPD object instance
    client = MPDClient()
    lcd = Adafruit_CharLCDPlate(1)

    lcd.clear()
    lcd.message("Wellcome to the\nMPD Interface!")
    print "Wellcome to the\nMPD Interface!"
    sleep(1)

    # initialize mpd connection
    startup(client, lcd)

    # Printing first known informations on lcd
    message = generate_status(client)
    display_status(lcd, message)

    print client.status()
    try:
        print client.listplaylists()
    except:
        print "error"
    try:
        print client.listplaylist()
    except:
        print "error"
    try:
        print client.listplaylistinfo()
    except:
        print "error"

        # Poll buttons, display message & set backlight accordingly
    btn = (
        (lcd.LEFT, "LEFT", lcd.ON),
        (lcd.UP, "UP", lcd.ON),
        (lcd.DOWN, "DOWN", lcd.ON),
        (lcd.RIGHT, "RIGHT", lcd.ON),
        (lcd.SELECT, "SELECT", lcd.ON),
    )

    t0 = clock()  # start time
    refresh_display = clock()  # time of the last display refresh
    last_action = clock()  # time of the last action
    prev = -1  # last pressed button

    while True:

        # refresh display every 0.1 sec
        if clock() - refresh_display >= 0.1:
            refresh_display = clock()
            # turn display after 5 sec off
            if clock() - last_action <= 2.5:
                message = generate_status(client)
                display_status(lcd, message)
            else:
                idle(lcd)

        for b in btn:
            # begin "if button pressed"
            if lcd.buttonPressed(b[0]):
                if (b is not prev) or (clock() - t0 >= 0.3):
                    if b[0] == lcd.UP:
                        BTN_UP(client)

                    elif b[0] == lcd.DOWN:
                        BTN_DOWN(client)

                    elif b[0] == lcd.RIGHT:
                        BTN_RIGHT(client)

                    elif b[0] == lcd.LEFT:
                        BTN_LEFT(client)

                    elif b[0] == lcd.SELECT:
                        BTN_SELECT(client)

                    t0 = clock()
                    last_action = clock()
                    prev = b
                break
                # end "if buffon pressed"

    client.disconnect()
    sys.exit(0)
开发者ID:Onkeliroh,项目名称:RaspberryPi-Scripts,代码行数:87,代码来源:mpd_controller.py


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