from Components.FileList import FileEntryComponent, FileList
from Components.MediaPlayer import PlayList, PlaylistEntryComponent
from Plugins.Plugin import PluginDescriptor
-from Tools.Directories import resolveFilename, SCOPE_MEDIA
+from Tools.Directories import resolveFilename, SCOPE_MEDIA, SCOPE_CONFIG
from Components.ServicePosition import ServicePositionGauge
from Screens.ChoiceBox import ChoiceBox
from Components.ServiceEventTracker import ServiceEventTracker
+from Components.Playlist import PlaylistIOInternal, PlaylistIOM3U, PlaylistIOPLS
from Screens.InfoBarGenerics import InfoBarSeek
+from ServiceReference import ServiceReference
+from Screens.ChoiceBox import ChoiceBox
import os
Screen.__init__(self, session)
self.oldService = self.session.nav.getCurrentlyPlayingServiceReference()
self.session.nav.stopService()
-
- self.filelist = FileList(resolveFilename(SCOPE_MEDIA), matchingPattern = "^.*\.(mp3|ogg|ts|wav|wave)", useServiceRef = True)
+
+ self.filelist = FileList(resolveFilename(SCOPE_MEDIA), matchingPattern = "^.*\.(mp3|ogg|ts|wav|wave|m3u|pls)", useServiceRef = True)
self["filelist"] = self.filelist
self.playlist = PlayList()
self.currList = "filelist"
+ self.playlistIOInternal = PlaylistIOInternal()
+ list = self.playlistIOInternal.open(resolveFilename(SCOPE_CONFIG, "playlist.e2"))
+ if list:
+ for x in list:
+ self.playlist.addFile(x.ref)
+ self.playlist.updateList()
+
def doNothing(self):
pass
def exit(self):
+ self.playlistIOInternal.clear()
+ for x in self.playlist.list:
+ self.playlistIOInternal.addService(ServiceReference(x[0]))
+ self.playlistIOInternal.save(resolveFilename(SCOPE_CONFIG, "playlist.e2"))
self.close()
def checkSkipShowHideLock(self):
self.playlist.addFile(x[0][0])
self.playlist.updateList()
+ ADDPLAYLIST = 0
+ REPLACEPLAYLIST = 1
+
def copyFile(self):
- 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)
+
def nextEntry(self):
next = self.playlist.getCurrentIndex() + 1