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


Python MPDClient.findadd方法代码示例

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


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

示例1: delete_event

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

#.........这里部分代码省略.........
                self.tree.append(["Toggle random [on]"])
            if options['single'] == '0':
                self.tree.append(["Toggle single [off]"])
            else:
                self.tree.append(["Toggle single [on]"])
            self.rbox.scroll_to_cell('0', column=None)
        size = self.window.get_default_size()
        self.window.resize(size[0], size[1]+50)
        self.lbox.hide()
        self.scrollbox.show()
        self.window.set_focus(self.rbox)
        self.nItr = self.tree.get_iter_root()


    def mpdCmd(self):
        if self.current == True:
            songTitle = self.tree.get_value(self.tree.get_iter_from_string(str(self.rbox.get_cursor()[0][0])), 0)
            songTitle = songTitle.split("\t")[0]
            songid = self.list[songTitle]
            self.mclient.playid(songid)
            self.music = False
            #self.mclient.disconnect()
            self.destroy(self, data=None)

        elif self.artist == True:
            #artist = self.tree.get_value(self.nItr, 0)
            artist = self.tree.get_value(self.tree.get_iter_from_string(str(self.rbox.get_cursor()[0][0])), 0)
            self.mclient.add(artist)
            self.mclient.play()

        elif self.album == True:
            #album = self.tree.get_value(self.nItr, 0)
            album = self.tree.get_value(self.tree.get_iter_from_string(str(self.rbox.get_cursor()[0][0])), 0)
            self.mclient.findadd("album", album)
            self.mclient.play()

        elif self.tracks == True:
            #track = self.tree.get_value(self.nItr, 0)
            track = self.tree.get_value(self.tree.get_iter_from_string(str(self.rbox.get_cursor()[0][0])), 0)
            self.mclient.findadd("title", track)
            self.mclient.play()

        elif self.delcur == True:
            track = self.tree.get_value(self.nItr, 0)
            self.mclient.deleteid(self.list[track])
            self.current = True
            self.delcur = False
            self.getMusic()
        
        elif self.options == True:
            option = self.tree.get_value(self.nItr, 0)
            if "consume" in option and "off" in option:
                self.mclient.consume(1)
            elif "consume" in option and "on" in option:
                self.mclient.consume(0)
            elif "repeat" in option and "off" in option:
                self.mclient.repeat(1)
            elif "repeat" in option  and "on" in option:
                self.mclient.repeat(0)
            elif "random" in option and "off" in option:
                self.mclient.random(1)
            elif "random" in option and "on" in option:
                self.mclient.random(0)
            elif "single" in option and "off" in option:
                self.mclient.single(1)
            elif "single" in option and "on" in option:
开发者ID:vincekd,项目名称:Pilaunch,代码行数:70,代码来源:pilaunch.py

示例2: library

# 需要导入模块: from mpd import MPDClient [as 别名]
# 或者: from mpd.MPDClient import findadd [as 别名]
class MPCWebSimple:
	"""Simple MPD Web Client

	GOALS
	CherryPyMPC 0.2 will be able to:
		- display playlist, file tree, and artist/album tree in different tabs
			(without reloading the whole page)
		- update the library (auto refresh when done)
		- seek in a song, graphically
		- be styled much better than 0.1 :-)

	REQS
		- python 2.x
		- python-mpd
		- cherrypy
		
	RUN
		- ./cherrypympc.py"""

# init
	def __init__(self, host, port, passw):
		self.__app__ = "CherryPyMPC 0.2 (static/iframe)"
		self.c = MPDClient()
		self.c.connect(host, port)
		if passw:
			self.c.password(passw)

# actions
	def play(self):
		self.c.play()
		raise cherrypy.HTTPRedirect("/")

	def pause(self):
		self.c.pause()
		raise cherrypy.HTTPRedirect("/")

	def stop(self):
		self.c.stop()
		raise cherrypy.HTTPRedirect("/")

	def prev(self):
		self.c.previous()
		raise cherrypy.HTTPRedirect("/")

	def next(self):
		self.c.next()
		raise cherrypy.HTTPRedirect("/")

	def playno(self, pos):
		if pos:
			self.c.playid(int(pos))
		raise cherrypy.HTTPRedirect("/")

	def addsong(self, song):
		self.c.add(song[1:-1])
		raise cherrypy.HTTPRedirect("/")

	def seek(self, pos, secs):
		self.c.seek(pos, secs)
		cherrypy.response.headers['content-type']='text/plain'
		return "OK"

	def update(self):
		self.c.update()
		cherrypy.response.headers['content-type']='text/plain'
		return "OK"

	def findadd(self, field, query, field2=None, query2=None):
		if field2 and query2:
			self.c.findadd(field, query, field2, query2)
		else:
			self.c.findadd(field, query)
		raise cherrypy.HTTPRedirect("/")

# subframe html
	def playlist(self):
		current_track = self.c.currentsong()['pos']
		plinfo = self.c.playlistinfo()
		pltable = "<table class='playlist'><tr class='header'><th>&nbsp;</th><th>Artist</th><th>Track</th><th>Lengtr</th></tr>"
		for item in plinfo:
			trclass = ""
			if item["pos"] == current_track:
				trclass = " class='currentsong'"
			pltable += "<tr{tr_class} onclick='top.location.href=\"/playno?pos={plpos}\"'><td><img src='/img/musicfile.png' /></td><td>{artist}</td><td>{title}</td><td class='tracklen'>{length}</td></tr>".format( \
					plpos=item["pos"],
					artist=item.get("artist", "&nbsp;"),
					title=item.get("title", item["file"].split("/")[-1]),
					length=SecToTimeString(item["time"]),
					tr_class=trclass)
		pltable += "</table>"
		return self.surround_head_tags_basic(pltable)

	def filetree(self):
		treelist = TreeList(self.c.list('file'))
		def make_ul(tlist, path=[], level=0):
			r = "<ul" + ("" if (level is not 0) else " class='tree'") + ">"
			if len(tlist) > 1:
				flist = sorted(tlist[1:])
				for filename in flist:
					liclass = "" if (filename is not flist[-1] or len(tlist[0].keys()) > 1) else " class='last'"
#.........这里部分代码省略.........
开发者ID:casmarrav,项目名称:cherrypympc,代码行数:103,代码来源:cherrypympc.py

示例3: __init__

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

#.........这里部分代码省略.........
		self.update_time = 500
		
		# Read specific config file for this server
		server_config = self.config_dir+self.server
		if os.path.isfile(server_config):
			for line in open(server_config):
				if line[0]!="#":
					try:
						if "update_time" in line:
							self.update_time = int(line.split("=")[-1].strip())
						elif "folder" in line:
							self.folder = line.split("=")[-1].strip()
					except:
						print "# Error reading server config file: "+server_config
						print "# Line: "+line
		self.music_list = self.folder+".music_list"
		print "+ Using music list: "+self.music_list
		
		
	def advance(self,mode,genre):
		test_speak_mode = not mode==self.mode
		test_speak_genre = not genre==self.genre
		test_speak_track = False	
		
		if genre=="": genre=="All"

		if mode=="track":
			self.c.stop()
			self.c.clear()
			#TODO - sub
			if genre=="All":
				self.c.add("")
			else:
				self.c.findadd("genre",genre)
			self.c.random(1)
			self.c.play()
			self.genre = genre
			self.mode = mode
			
		elif mode=="album":
			if genre=="All":
				self.some_albums = list(self.albums)
				# Increment counter down through list
				if not "All" in self.i:
					self.i["All"]=len(self.some_albums)-1
				else:
					self.i["All"] = self.i["All"]-1

				if self.i["All"]<0:
					self.i["All"]=len(self.some_albums)-1
			else:
				# Build album list if genre has changed
				if not self.last_genre==genre:
					self.some_albums = []
					for a in self.albums:
						if a[0]==genre:
							self.some_albums.append(a)

				# Increment counter up through sub list
				if not genre in self.i:
					self.i[genre]=0
				else:
					self.i[genre]=self.i[genre]+1
				
				if self.i[genre]>len(self.some_albums)-1:
					self.i[genre]=0
开发者ID:Bisxuit,项目名称:dukebox,代码行数:70,代码来源:dukebox_player.py

示例4: MPDClient

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

playing = False
api_url = 'http://46.101.216.59:3000/api/state'
client = MPDClient()       # create client object
print("Connecting to MPD")
client.connect('localhost', 6600)  # connect to localhost:6600
print(" MPD Version is " +  client.mpd_version)           # print the mpd version
client.clear()
print(client.findadd('track', 'barry white'))        

while True:
    time.sleep(0.05)
    r = requests.get(api_url)
    print(r.text)
    if r.status_code == 200:
        status = json.loads(r.text)
        print(client.currentsong())
        if status['on'] == True and playing == False:
            client.play()
            playing = True
        elif not status['on']:
            client.stop()
            playing = False


开发者ID:Timka21213,项目名称:junction-2015,代码行数:29,代码来源:poll-music.py


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