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


Python MPDClient.listplaylistinfo方法代码示例

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


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

示例1: play

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

示例2: addSong

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import listplaylistinfo [as 别名]
def addSong(stdscr, selectedSongNumber):
	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("localhost", 6600)  # connect to localhost:6600
	songs=client.listplaylistinfo("TC Jukebox")
	client.consume(1)

	if selectedSongNumber==30:
		selectedSong=songs[selectedSongNumber]
		songid=client.addid(selectedSong['file'], 0)
		client.play(0)
		drawRick(stdscr)
	elif selectedSongNumber==98:
		client.clear()

	elif selectedSongNumber<100:
		selectedSong=songs[selectedSongNumber]
		#stdscr.addstr(50,5,str(selectedSong['file']))
		client.add(selectedSong['file'])
		drawScreen(stdscr)

	client.close()                     # send the close command
	client.disconnect()
开发者ID:DigitalHarborFoundation,项目名称:piJukebox,代码行数:26,代码来源:piJukebox.py

示例3: main

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

示例4: drawScreen

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import listplaylistinfo [as 别名]
def drawScreen(stdscr):
	logging.debug("Drawing Screen\n")
	global maxHeight
	global maxWidth

	if x=='blank':
		stdscr.erase()

		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("localhost", 6600)  # connect to localhost:6600
		client.consume(1)

		songs=client.listplaylistinfo(playlistName) # print result of the command find playlist

		stdscr.addstr(0,35," _______   __    __   _______           __   __    __   __  ___  _______    .______     ______   ___   ___ ")
		stdscr.addstr(1,35,"|       \ |  |  |  | |   ____|         |  | |  |  |  | |  |/  / |   ____|   |   _  \   /  __  \  \  \ /  / ")
		stdscr.addstr(2,35,"|  .--.  ||  |__|  | |  |__            |  | |  |  |  | |  '  /  |  |__      |  |_)  | |  |  |  |  \  V  /  ")
		stdscr.addstr(3,35,"|  |  |  ||   __   | |   __|     .--.  |  | |  |  |  | |    <   |   __|     |   _  <  |  |  |  |   >   <   ")
		stdscr.addstr(4,35,"|  '--'  ||  |  |  | |  |        |  `--'  | |  `--'  | |  .  \  |  |____    |  |_)  | |  `--'  |  /  .  \  ")
		stdscr.addstr(5,35,"|_______/ |__|  |__| |__|         \______/   \______/  |__|\__\ |_______|   |______/   \______/  /__/ \__\ ")

		curses.echo()            # Enable echoing of characters
		stdscr.addstr(2,3, "Enter 2 Digit Song Number: ")

		rectangle(stdscr, 1,0, 5, 30)


		maxHeight, maxWidth =stdscr.getmaxyx()

		colCount=1
		rowCount=1
		yStart=6
		xStart=2
		maxRows= ((maxHeight-5)) - yStart
		maxStringLength=(maxWidth/2 - 13) / 2

		songStart=0

		for song in songs:
			songStart+=1

			artist= song['artist']
			artist= (artist[:maxStringLength] + '...') if len(artist) > maxStringLength else artist

			songTitle=song['title']
			songTitle=(songTitle[:maxStringLength] + '...') if len(songTitle) > maxStringLength else songTitle

			if(rowCount < maxRows):
				# stdscr.addstr(yStart+rowCount,xStart,str(rowCount) + " of " + str(maxRows))
				# logging.debug(str(rowCount) + " of " + str(maxRows) + "\n")
				# logging.debug(str(songStart).zfill(2) + ". " +  songTitle + " (" + artist + ")")
				stdscr.addstr(yStart+rowCount,xStart,str(songStart).zfill(2) + ". " +  songTitle + " (" + artist + ")" )

			#stdscr.addstr(yStart+rowCount,xStart,str(song))

			rowCount+=1
			if rowCount > maxRows :
				rowCount=1
				xStart=maxWidth/2

		status=client.status()
		if status['state']=="stop":
			client.play()

		client.close()                     # send the close command
		client.disconnect()

		stdscr.refresh()

		drawSongs(stdscr)
开发者ID:DigitalHarborFoundation,项目名称:piJukebox,代码行数:74,代码来源:piJukebox.py


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