allow burning DVDs with multiple titles where playback automatically jumps to the...
[enigma2.git] / lib / python / Plugins / Extensions / MediaPlayer / plugin.py
index f87978bd86ca05bb1564b276be80efbcf8c463ee..e1e0e2269e57f6683594cebda4cbc0611f918b66 100644 (file)
@@ -6,7 +6,7 @@ from Screens.MessageBox import MessageBox
 from Screens.InputBox import InputBox
 from Components.ActionMap import NumberActionMap, HelpableActionMap
 from Components.Label import Label
-from Components.Pixmap import Pixmap
+from Components.Pixmap import Pixmap,MultiPixmap
 from Components.Label import Label
 from Components.FileList import FileList
 from Components.MediaPlayer import PlayList
@@ -87,7 +87,9 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB
                self["genretext"] = Label(_("Genre:"))
                self["genre"] = Label("")
                self["coverArt"] = MediaPixmap()
+               self["repeat"] = MultiPixmap()
 
+               self.repeat = False
                self.seek_target = None
 
                class MoviePlayerActionMap(NumberActionMap):
@@ -225,19 +227,25 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB
                        sAlbum = currPlay.info().getInfoString(iServiceInformation.sAlbum)
                        sGenre = currPlay.info().getInfoString(iServiceInformation.sGenre)
                        sArtist = currPlay.info().getInfoString(iServiceInformation.sArtist)
+                       sYear = ""
 
                        if sTitle == "":
-                               sTitle = currPlay.info().getName().split('/')[-1]
+                               if not self.isAudioCD:
+                                       sTitle = currPlay.info().getName().split('/')[-1]
+                               else:
+                                       sTitle = self.playlist.getServiceRefList()[self.playlist.getCurrentIndex()].getName()
 
                        if self.AudioCD_albuminfo:
-                               if sAlbum == "" and "TITLE" in self.AudioCD_albuminfo:
-                                       sAlbum = self.AudioCD_albuminfo["TITLE"]
-                               if sGenre == "" and "GENRE" in self.AudioCD_albuminfo:
-                                       sGenre = self.AudioCD_albuminfo["GENRE"]
-                               if sArtist == "" and "PERFORMER" in self.AudioCD_albuminfo:
-                                       sArtist = self.AudioCD_albuminfo["PERFORMER"]
-
-                       self.updateMusicInformation( artist = sArtist, title = sTitle, album = sAlbum, genre = sGenre, clear = True )
+                               if sAlbum == "" and "title" in self.AudioCD_albuminfo:
+                                       sAlbum = self.AudioCD_albuminfo["title"]
+                               if sGenre == "" and "genre" in self.AudioCD_albuminfo:
+                                       sGenre = self.AudioCD_albuminfo["genre"]
+                               if sArtist == "" and "artist" in self.AudioCD_albuminfo:
+                                       sArtist = self.AudioCD_albuminfo["artist"]
+                               if "year" in self.AudioCD_albuminfo:
+                                       sYear = self.AudioCD_albuminfo["year"]
+
+                       self.updateMusicInformation( sArtist, sTitle, sAlbum, sYear, sGenre, clear = True )
                else:
                        self.updateMusicInformation()
 
@@ -431,6 +439,7 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB
                menu.append((_("save playlist"), "saveplaylist"));
                menu.append((_("load playlist"), "loadplaylist"));
                menu.append((_("delete saved playlist"), "deleteplaylist"));
+               menu.append((_("repeat playlist"), "repeat"));
                self.session.openWithCallback(self.menuCallback, ChoiceBox, title="", list=menu)
 
        def menuCallback(self, choice):
@@ -466,7 +475,13 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB
                        self.delete_saved_playlist()
                elif choice[1] == "shuffle":
                        self.playlist.PlayListShuffle()
-
+               elif choice[1] == "repeat":
+                       if self.repeat == True:
+                               self.repeat = False
+                               self["repeat"].setPixmapNum(0)
+                       else:
+                               self.repeat = True
+                               self["repeat"].setPixmapNum(1)
 
        def showEventInformation(self):
                from Screens.EventView import EventViewSimple
@@ -593,6 +608,9 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB
                next = self.playlist.getCurrentIndex() + 1
                if next < len(self.playlist):
                        self.changeEntry(next)
+               elif ( len(self.playlist) > 0 ) and ( self.repeat == True ):
+                       self.stopEntry()
+                       self.changeEntry(0)
 
        def nextMarkOrEntry(self):
                if not self.jumpPreviousNextMark(lambda x: x):
@@ -723,7 +741,6 @@ class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoB
        def unPauseService(self):
                self.setSeekState(self.SEEK_STATE_PLAY)
 
-
 class MediaPlayerLCDScreen(Screen):
        skin = """
        <screen position="0,0" size="132,64" title="LCD Text">
@@ -767,7 +784,11 @@ def filescan_open(list, session, **kwargs):
 
        mp.switchToPlayList()
        for file in list:
-               ref = eServiceReference(4097, 0, file.path)
+               if file.mimetype == "video/MP2T":
+                       stype = 1
+               else:
+                       stype = 4097
+               ref = eServiceReference(stype, 0, file.path)
                mp.playlist.addFile(ref)
 
        # TODO: rather play first than last file?
@@ -782,35 +803,20 @@ def audioCD_open(list, session, **kwargs):
        mp.playlist.clear()
        mp.isAudioCD = True
 
-       mp.switchToPlayList()
-       cdtext = popen('cdtextinfo -l').read()
-       tracklist = []
-       if cdtext is not "":
-               tracklist = cdtext.splitlines()
-               cdtext = popen('cdtextinfo -a').read()
-               if cdtext is not "":
-                       albumtags = cdtext.splitlines()
-                       for tag in albumtags:
-                               tag = tag.split(':',1)
-                               mp.AudioCD_albuminfo[tag[0]] = tag[1]
-                       print mp.AudioCD_albuminfo
-       idx = 0
        for file in list:
                ref = eServiceReference(4097, 0, file.path)
-               if idx < len(tracklist):
-                       track = tracklist[idx]
-                       ref.setName("%d - %s" % (int(track.split(':',1)[0]), track.split(':')[1]))
-                       idx += 1
                mp.playlist.addFile(ref)
+       from Plugins.Extensions.CDInfo.plugin import Query
+       cdinfo = Query(mp)
+       cdinfo.scan()
 
        mp.changeEntry(0)
-       mp.playlist.updateList()
        mp.switchToPlayList()
 
 def filescan(**kwargs):
        from Components.Scanner import Scanner, ScanPath
-       return [
-               Scanner(mimetypes = ["video/mpeg"],
+       mediatypes = [
+               Scanner(mimetypes = ["video/mpeg", "video/MP2T"],
                        paths_to_scan =
                                [
                                        ScanPath(path = "", with_subdirs = False),
@@ -827,8 +833,10 @@ def filescan(**kwargs):
                        name = "Music",
                        description = "Play Music...",
                        openfnc = filescan_open,
-               ),
-               Scanner(mimetypes = ["audio/x-cda", "audio/x-wav"],
+               )]
+       try:
+               from Plugins.Extensions.CDInfo.plugin import Query
+               mediatypes.insert(0,Scanner(mimetypes = ["audio/x-cda", "audio/x-wav"],
                        paths_to_scan =
                                [
                                        ScanPath(path = "", with_subdirs = False),
@@ -836,8 +844,10 @@ def filescan(**kwargs):
                        name = "Audio-CD",
                        description = "Play Audio-CD...",
                        openfnc = audioCD_open,
-               )
-       ]
+               ))
+               return mediatypes
+       except ImportError:
+               return mediatypes
 
 from Plugins.Plugin import PluginDescriptor
 def Plugins(**kwargs):