本文整理汇总了Python中playlist.Playlist.setlibrary方法的典型用法代码示例。如果您正苦于以下问题:Python Playlist.setlibrary方法的具体用法?Python Playlist.setlibrary怎么用?Python Playlist.setlibrary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类playlist.Playlist
的用法示例。
在下文中一共展示了Playlist.setlibrary方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from playlist import Playlist [as 别名]
# 或者: from playlist.Playlist import setlibrary [as 别名]
#.........这里部分代码省略.........
self.playlist.add(PlaylistItem(*user_in[2:]))
return "Adding..." #NEEDS EXIT SPECIFICATION
else:
return "[ADD] Incorrect number of arguments!"
elif user_in[1] == "DIRADD":
if len(user_in[2:]) == 1:
return self.playlist.add_dir(user_in[2])
else:
return "[DIRADD] Incorrect number of arguments!"
elif user_in[1] == "SHOW":
return self.playlist.show()
elif user_in[1] == "CLEAR":
return self.playlist.clear()
elif user_in[1] == "SHUFFLE":
self.playlist.randomize()
if self.playing:
self.play()
return "Randomized playlist:\n %s" % self.playlist.show()
else:
return "Unknown PLAYLIST command."
except IndexError:
return self.playlist.show()
except:
raise
elif user_in[0] == "PLAY":
return self.play()
elif user_in[0] == "NEXT":
return self.next()
elif user_in[0] == "PREVIOUS":
return self.prev()
elif user_in[0] == "JUMP":
try: return self.jump(user_in[1])
except: return "No track number supplied."
elif user_in[0] == "STOP":
return self.stop()
elif user_in[0] == "REPEAT":
self.playlist.repeat = not(self.playlist.repeat)
return "REPEAT is now %s" % ("ON" if self.playlist.repeat else "OFF")
elif user_in[0] == "LIBRARY":
try:
return "%s" % self.playlist.setlibrary(user_in[1])
except IndexError:
return "Current library PATH is: %s" % Playlist.root
elif user_in[0] == "VOLUME":
try:
if user_in[1] == "UP":
return self.adjustVolume(1)
elif user_in[1] == "DOWN":
return self.adjustVolume(-1)
else:
return "Unknown argument"
except IndexError:
return "Current volume is %s" % str(MusicPlayer.volume) + "dB"
elif user_in[0] == "ERRORLOG":
return "\n".join(self.errorlog)
elif user_in[0] == "STATUS":
return "%s" % " ".join(self.current_out)
else:
return "Unknown command."
def play(self):
if self.playlist.len() > 0:
if not(self.prun):
self.openPlayer()
self.send("LOAD %s" % self.playlist.get_path())
self.playing = True
return "Started playing"
else:
self.playing = False
return "Cannot play, empty playlist."
def stop(self):
self.playing = False
self.stopPlayer()
return "Playback stopped."
def next(self):
if self.playlist.next() and self.playing:
self.play()
return "Now playing item %d: %s - %s" % (self.playlist.cursor+1,self.playlist[self.playlist.cursor].artist,self.playlist[self.playlist.cursor].title)
else:
self.stop()
try:
return "Moved cursor to item %d: %s - %s" % (self.playlist.cursor+1,self.playlist[self.playlist.cursor].artist,self.playlist[self.playlist.cursor].title)
except IndexError:
return "Can't move cursor, empty playlist"
def prev(self):
self.playlist.prev(self.playing)
if self.playing:
self.play()
return "Moved to item: %s" % self.playlist.cursor + 1
def jump(self,cursor):
if self.playlist.jump(cursor):
if self.playing:
self.play()
return "Jumped to %s" % cursor
else:
return "Error: [%r] is not a valid playlist track number" % cursor