- self.playlist.addFile(self.filelist.getServiceRef())
- self.playlist.updateList()
- if len(self.playlist) == 1:
- self.changeEntry(0)
+ if self.filelist.getServiceRef().type == 4098: # playlist
+ list = []
+ list.append((_("Add files to playlist"), (self.ADDPLAYLIST, self.filelist.getServiceRef())))
+ list.append((_("Replace current playlist"), (self.REPLACEPLAYLIST, self.filelist.getServiceRef())))
+ self.session.openWithCallback(self.playlistCallback, ChoiceBox, title=_("You selected a playlist"), list = list)
+ else:
+ self.playlist.addFile(self.filelist.getServiceRef())
+ self.playlist.updateList()
+ if len(self.playlist) == 1:
+ self.changeEntry(0)
+
+ def playlistCallback(self, answer):
+ if answer is not None:
+ extension = answer[1][1].getPath()[-3:]
+ if extension == "m3u":
+ playlist = PlaylistIOM3U()
+ elif extension == "pls":
+ playlist = PlaylistIOPLS()
+ if answer[1][0] == self.REPLACEPLAYLIST:
+ self.stopEntry()
+ self.playlist.clear()
+ self.switchToFileList()
+ if answer[1][0] == self.REPLACEPLAYLIST or answer[1][0] == self.ADDPLAYLIST:
+ list = playlist.open(answer[1][1].getPath())
+ for x in list:
+ self.playlist.addFile(x.ref)
+