2009-07-13 23:17:53 -04:00
|
|
|
from list import List
|
2009-07-29 18:12:04 -04:00
|
|
|
import random
|
|
|
|
from menuItem import MenuItem
|
2009-07-13 23:17:53 -04:00
|
|
|
|
|
|
|
class Playlist(List):
|
2009-08-02 16:04:33 -04:00
|
|
|
def __init__(self,data,queue,funcs):
|
|
|
|
List.__init__(self,data,"Playlist",funcs)
|
2009-07-29 18:12:04 -04:00
|
|
|
self.queue = queue
|
|
|
|
self.makeRCMenu()
|
|
|
|
|
|
|
|
|
|
|
|
def visible(self,func):
|
|
|
|
List.visible(self,func)
|
|
|
|
if (func == "show") and (self.populated == False):
|
2009-08-02 20:09:04 -04:00
|
|
|
self.populate()
|
2009-07-29 18:12:04 -04:00
|
|
|
|
2009-08-02 20:09:04 -04:00
|
|
|
|
|
|
|
def populate(self):
|
|
|
|
for file in self.data.curList:
|
|
|
|
List.insert(self,file)
|
|
|
|
List.populate(self)
|
|
|
|
|
|
|
|
|
|
|
|
# Insert songs into the list
|
2009-07-29 18:12:04 -04:00
|
|
|
def insert(self,file):
|
|
|
|
if self.populated == False:
|
2009-08-02 20:09:04 -04:00
|
|
|
self.populate()
|
2009-07-29 18:12:04 -04:00
|
|
|
List.insert(self,file)
|
|
|
|
self.data.curList+=[file]
|
|
|
|
|
|
|
|
|
|
|
|
def drop(self):
|
|
|
|
List.drop(self)
|
|
|
|
self.data.curList = []
|
|
|
|
|
|
|
|
|
|
|
|
def getNext(self):
|
|
|
|
# If random is true, give back a random song
|
|
|
|
max = len(self.filter) - 1
|
|
|
|
if max == -1:
|
|
|
|
return False
|
|
|
|
if self.data.random == True:
|
|
|
|
self.data.curSong = self.filter[random.randint(0,max)][0]
|
|
|
|
# Otherwise, give back next non-filtered song
|
|
|
|
else:
|
|
|
|
next = self.filter[0][0]
|
|
|
|
for i in range(max):
|
|
|
|
if self.filter[i][0]==self.data.curSong:
|
|
|
|
next = self.filter[i+1][0]
|
|
|
|
break
|
|
|
|
self.data.curSong = next
|
|
|
|
self.loadSong(self.data.library.files[self.data.curSong])
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
|
|
def makeRCMenu(self):
|
|
|
|
List.makeRCMenu(self)
|
|
|
|
toQ = MenuItem("Add to queue",self.addToQ,None,None,None)
|
|
|
|
self.rcmenu.prepend(toQ)
|
|
|
|
|
|
|
|
|
|
|
|
def addToQ(self,widgit,func,data):
|
|
|
|
self.selection(self.queue.insert)
|
|
|
|
self.queue.filterRows("")
|
2009-07-29 19:30:06 -04:00
|
|
|
|
|
|
|
|
|
|
|
def filterQuick(self,string):
|
|
|
|
List.filterQuick(self,self.data.curList,string)
|