+ elif choice[1] == "saveplaylist":
+ self.save_playlist()
+ elif choice[1] == "loadplaylist":
+ self.load_playlist()
+ elif choice[1] == "deleteplaylist":
+ self.delete_saved_playlist()
+ elif choice[1] == "shuffle":
+ self.playlist.PlayListShuffle()
+
+
+ def showEventInformation(self):
+ from Screens.EventView import EventViewSimple
+ from ServiceReference import ServiceReference
+ evt = self[self.currList].getCurrentEvent()
+ if evt:
+ self.session.open(EventViewSimple, evt, ServiceReference(self.getCurrent()))
+
+ # also works on filelist (?)
+ def getCurrent(self):
+ return self["playlist"].getCurrent()
+
+ def deletePlaylistEntry(self):
+ if self.currList == "playlist":
+ if self.playlist.getSelectionIndex() == self.playlist.getCurrentIndex():
+ self.stopEntry()
+ self.deleteEntry()
+
+ def skip_listbegin(self):
+ if self.currList == "filelist":
+ self.filelist.moveToIndex(0)
+ else:
+ self.playlist.moveToIndex(0)
+ self.updateCurrentInfo()
+
+ def skip_listend(self):
+ if self.currList == "filelist":
+ idx = len(self.filelist.list)
+ self.filelist.moveToIndex(idx - 1)
+ else:
+ self.playlist.moveToIndex(len(self.playlist)-1)
+ self.updateCurrentInfo()
+
+ def save_playlist(self):
+ self.session.openWithCallback(self.save_playlist2,InputBox, title=_("Please enter filename (empty = use current date)"),windowTitle = _("Save Playlist"))
+
+ def save_playlist2(self, name):
+ if name is not None:
+ name = name.strip()
+ if name == "":
+ name = strftime("%y%m%d_%H%M%S")
+ name += ".e2pls"
+ self.playlistIOInternal.clear()
+ for x in self.playlist.list:
+ self.playlistIOInternal.addService(ServiceReference(x[0]))
+ self.playlistIOInternal.save(resolveFilename(SCOPE_PLAYLIST) + name)
+
+ def load_playlist(self):
+ listpath = []
+ playlistdir = resolveFilename(SCOPE_PLAYLIST)
+ try:
+ for i in os_listdir(playlistdir):
+ listpath.append((i,playlistdir + i))
+ except IOError,e:
+ print "Error while scanning subdirs ",e
+ self.session.openWithCallback(self.PlaylistSelected, ChoiceBox, title=_("Please select a playlist..."), list = listpath)
+
+ def PlaylistSelected(self,path):
+ if path is not None:
+ self.clear_playlist()
+ self.playlistIOInternal = PlaylistIOInternal()
+ list = self.playlistIOInternal.open(path[1])
+ if list:
+ for x in list:
+ self.playlist.addFile(x.ref)
+ self.playlist.updateList()
+
+ def delete_saved_playlist(self):
+ listpath = []
+ playlistdir = resolveFilename(SCOPE_PLAYLIST)
+ try:
+ for i in os_listdir(playlistdir):
+ listpath.append((i,playlistdir + i))
+ except IOError,e:
+ print "Error while scanning subdirs ",e
+ self.session.openWithCallback(self.DeletePlaylistSelected, ChoiceBox, title=_("Please select a playlist to delete..."), list = listpath)
+
+ def DeletePlaylistSelected(self,path):
+ if path is not None:
+ self.delname = path[1]
+ self.session.openWithCallback(self.deleteConfirmed, MessageBox, _("Do you really want to delete %s?") % (path[1]))
+
+ def deleteConfirmed(self, confirmed):
+ if confirmed:
+ os_remove(self.delname)
+
+ def clear_playlist(self):
+ self.stopEntry()
+ self.playlist.clear()
+ self.switchToFileList()