1 from os import path as os_path, remove as os_remove, listdir as os_listdir, popen
2 from time import strftime
3 from enigma import iPlayableService, eTimer, eServiceCenter, iServiceInformation
4 from Screens.Screen import Screen
5 from Screens.MessageBox import MessageBox
6 from Screens.InputBox import InputBox
7 from Components.ActionMap import NumberActionMap, HelpableActionMap
8 from Components.Label import Label
9 from Components.Pixmap import Pixmap,MultiPixmap
10 from Components.Label import Label
11 from Components.FileList import FileList
12 from Components.MediaPlayer import PlayList
13 from Tools.Directories import resolveFilename, SCOPE_CONFIG, SCOPE_PLAYLIST, SCOPE_SKIN_IMAGE
14 from Components.ServicePosition import ServicePositionGauge
15 from Components.ServiceEventTracker import ServiceEventTracker, InfoBarBase
16 from Components.Playlist import PlaylistIOInternal, PlaylistIOM3U, PlaylistIOPLS
17 from Screens.InfoBarGenerics import InfoBarSeek, InfoBarAudioSelection, InfoBarCueSheetSupport, InfoBarNotifications, InfoBarSubtitleSupport
18 from ServiceReference import ServiceReference
19 from Screens.ChoiceBox import ChoiceBox
20 from Screens.HelpMenu import HelpableScreen
21 from Components.Harddisk import harddiskmanager
22 from Tools.Directories import fileExists, pathExists
25 class MyPlayList(PlayList):
27 PlayList.__init__(self)
29 def PlayListShuffle(self):
30 random.shuffle(self.list)
31 self.l.setList(self.list)
33 self.oldCurrPlaying = -1
35 class MediaPixmap(Pixmap):
36 def applySkin(self, desktop, screen):
37 self.default_pixmap = None
38 if self.skinAttributes is not None:
39 for (attrib, value) in self.skinAttributes:
40 if attrib == "pixmap":
41 self.default_pixmap = value
43 if self.default_pixmap is None:
44 self.default_pixmap = resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/no_coverArt.png")
45 return Pixmap.applySkin(self, desktop, screen)
47 class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoBarCueSheetSupport, InfoBarNotifications, InfoBarSubtitleSupport, HelpableScreen):
49 ENABLE_RESUME_SUPPORT = True
51 def __init__(self, session, args = None):
52 Screen.__init__(self, session)
53 InfoBarAudioSelection.__init__(self)
54 InfoBarCueSheetSupport.__init__(self, actionmap = "MediaPlayerCueSheetActions")
55 InfoBarNotifications.__init__(self)
56 InfoBarBase.__init__(self)
57 InfoBarSubtitleSupport.__init__(self)
58 HelpableScreen.__init__(self)
60 self.oldService = self.session.nav.getCurrentlyPlayingServiceReference()
61 self.session.nav.stopService()
63 self.playlistparsers = {}
64 self.addPlaylistParser(PlaylistIOM3U, "m3u")
65 self.addPlaylistParser(PlaylistIOPLS, "pls")
66 self.addPlaylistParser(PlaylistIOInternal, "e2pls")
68 # 'None' is magic to start at the list of mountpoints
69 self.filelist = FileList(None, matchingPattern = "(?i)^.*\.(mp3|ogg|ts|wav|wave|m3u|pls|e2pls|mpg|vob|avi|mkv|dat|flac)", useServiceRef = True, additionalExtensions = "4098:m3u 4098:e2pls 4098:pls")
70 self["filelist"] = self.filelist
72 self.playlist = MyPlayList()
73 #self.playlist = PlayList()
74 self.is_closing = False
76 self["playlist"] = self.playlist
78 self["PositionGauge"] = ServicePositionGauge(self.session.nav)
80 self["currenttext"] = Label("")
82 self["artisttext"] = Label(_("Artist:"))
83 self["artist"] = Label("")
84 self["titletext"] = Label(_("Title:"))
85 self["title"] = Label("")
86 self["albumtext"] = Label(_("Album:"))
87 self["album"] = Label("")
88 self["yeartext"] = Label(_("Year:"))
89 self["year"] = Label("")
90 self["genretext"] = Label(_("Genre:"))
91 self["genre"] = Label("")
92 self["coverArt"] = MediaPixmap()
93 self["repeat"] = MultiPixmap()
96 self.seek_target = None
98 class MoviePlayerActionMap(NumberActionMap):
99 def __init__(self, player, contexts = [ ], actions = { }, prio=0):
100 NumberActionMap.__init__(self, contexts, actions, prio)
103 def action(self, contexts, action):
105 return NumberActionMap.action(self, contexts, action)
108 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
110 "ok": (self.ok, _("add file to playlist")),
111 "cancel": (self.exit, _("exit mediaplayer")),
114 self["MediaPlayerActions"] = HelpableActionMap(self, "MediaPlayerActions",
116 "play": (self.xplayEntry, _("play entry")),
117 "pause": (self.pauseEntry, _("pause")),
118 "stop": (self.stopEntry, _("stop entry")),
119 "previous": (self.previousMarkOrEntry, _("play from previous mark or playlist entry")),
120 "next": (self.nextMarkOrEntry, _("play from next mark or playlist entry")),
121 "menu": (self.showMenu, _("menu")),
122 "skipListbegin": (self.skip_listbegin, _("jump to listbegin")),
123 "skipListend": (self.skip_listend, _("jump to listend")),
124 "prevBouquet": (self.switchToPlayList, _("switch to playlist")),
125 "nextBouquet": (self.switchToFileList, _("switch to filelist")),
126 "delete": (self.deletePlaylistEntry, _("delete playlist entry")),
127 "shift_stop": (self.clear_playlist, _("clear playlist")),
128 "shift_record": (self.playlist.PlayListShuffle, _("shuffle playlist")),
129 "subtitles": (self.subtitleSelection, _("Subtitle selection")),
132 self["InfobarEPGActions"] = HelpableActionMap(self, "InfobarEPGActions",
134 "showEventInfo": (self.showEventInformation, _("show event details")),
137 self["actions"] = MoviePlayerActionMap(self, ["DirectionActions"],
139 "right": self.rightDown,
140 "rightRepeated": self.doNothing,
141 "rightUp": self.rightUp,
142 "left": self.leftDown,
143 "leftRepeated": self.doNothing,
144 "leftUp": self.leftUp,
147 "upRepeated": self.up,
148 "upUp": self.doNothing,
150 "downRepeated": self.down,
151 "downUp": self.doNothing,
154 InfoBarSeek.__init__(self, actionmap = "MediaPlayerSeekActions")
156 self.onClose.append(self.delMPTimer)
157 self.onClose.append(self.__onClose)
159 self.righttimer = False
160 self.rightKeyTimer = eTimer()
161 self.rightKeyTimer.callback.append(self.rightTimerFire)
163 self.lefttimer = False
164 self.leftKeyTimer = eTimer()
165 self.leftKeyTimer.callback.append(self.leftTimerFire)
167 self.currList = "filelist"
169 self.coverArtFileName = ""
170 self.isAudioCD = False
171 self.AudioCD_albuminfo = {}
172 self.savePlaylistOnExit = True
174 self.playlistIOInternal = PlaylistIOInternal()
175 list = self.playlistIOInternal.open(resolveFilename(SCOPE_CONFIG, "playlist.e2pls"))
178 self.playlist.addFile(x.ref)
179 self.playlist.updateList()
181 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
183 iPlayableService.evUpdatedInfo: self.__evUpdatedInfo,
184 iPlayableService.evUser+11: self.__evDecodeError,
185 iPlayableService.evUser+12: self.__evPluginError
191 def createSummary(self):
192 return MediaPlayerLCDScreen
195 self.session.openWithCallback(self.exitCB, MessageBox, _("Do you really want to exit?"), timeout=5)
197 def exitCB(self, answer):
199 self.playlistIOInternal.clear()
200 for x in self.playlist.list:
201 self.playlistIOInternal.addService(ServiceReference(x[0]))
202 if self.savePlaylistOnExit:
203 self.playlistIOInternal.save(resolveFilename(SCOPE_CONFIG, "playlist.e2pls"))
206 def checkSkipShowHideLock(self):
207 self.updatedSeekState()
209 def doEofInternal(self, playing):
216 self.session.nav.playService(self.oldService)
218 def __evUpdatedInfo(self):
219 currPlay = self.session.nav.getCurrentService()
220 currenttitle = currPlay.info().getInfo(iServiceInformation.sCurrentTitle)
221 totaltitles = currPlay.info().getInfo(iServiceInformation.sTotalTitles)
222 sTitle = currPlay.info().getInfoString(iServiceInformation.sTitle)
223 print "[__evUpdatedInfo] title %d of %d (%s)" % (currenttitle, totaltitles, sTitle)
224 self.readTitleInformation()
226 def __evDecodeError(self):
227 currPlay = self.session.nav.getCurrentService()
228 sVideoType = currPlay.info().getInfoString(iServiceInformation.sVideoType)
229 print "[__evDecodeError] video-codec %s can't be decoded by hardware" % (sVideoType)
230 self.session.open(MessageBox, _("This Dreambox can't decode %s video streams!") % sVideoType, type = MessageBox.TYPE_INFO,timeout = 20 )
232 def __evPluginError(self):
233 currPlay = self.session.nav.getCurrentService()
234 message = currPlay.info().getInfoString(iServiceInformation.sUser+12)
235 print "[__evPluginError]" , message
236 self.session.open(MessageBox, ("GStreamer Error: missing %s") % message, type = MessageBox.TYPE_INFO,timeout = 20 )
238 def delMPTimer(self):
239 del self.rightKeyTimer
240 del self.leftKeyTimer
242 def readTitleInformation(self):
243 currPlay = self.session.nav.getCurrentService()
244 if currPlay is not None:
245 sTitle = currPlay.info().getInfoString(iServiceInformation.sTitle)
246 sAlbum = currPlay.info().getInfoString(iServiceInformation.sAlbum)
247 sGenre = currPlay.info().getInfoString(iServiceInformation.sGenre)
248 sArtist = currPlay.info().getInfoString(iServiceInformation.sArtist)
249 sYear = currPlay.info().getInfoString(iServiceInformation.sTimeCreate)
252 if not self.isAudioCD:
253 sTitle = currPlay.info().getName().split('/')[-1]
255 sTitle = self.playlist.getServiceRefList()[self.playlist.getCurrentIndex()].getName()
257 if self.AudioCD_albuminfo:
258 if sAlbum == "" and "title" in self.AudioCD_albuminfo:
259 sAlbum = self.AudioCD_albuminfo["title"]
260 if sGenre == "" and "genre" in self.AudioCD_albuminfo:
261 sGenre = self.AudioCD_albuminfo["genre"]
262 if sArtist == "" and "artist" in self.AudioCD_albuminfo:
263 sArtist = self.AudioCD_albuminfo["artist"]
264 if "year" in self.AudioCD_albuminfo:
265 sYear = self.AudioCD_albuminfo["year"]
267 self.updateMusicInformation( sArtist, sTitle, sAlbum, sYear, sGenre, clear = True )
269 self.updateMusicInformation()
271 def updateMusicInformation(self, artist = "", title = "", album = "", year = "", genre = "", clear = False):
272 self.updateSingleMusicInformation("artist", artist, clear)
273 self.updateSingleMusicInformation("title", title, clear)
274 self.updateSingleMusicInformation("album", album, clear)
275 self.updateSingleMusicInformation("year", year, clear)
276 self.updateSingleMusicInformation("genre", genre, clear)
278 def updateSingleMusicInformation(self, name, info, clear):
279 if info != "" or clear:
280 if self[name].getText() != info:
281 self[name].setText(info)
283 def updateCoverArtPixmap(self, path):
284 while not path.endswith("/"):
286 pngname = path + "folder.png"
288 if not fileExists(pngname):
289 pngname = self["coverArt"].default_pixmap
290 if self.coverArtFileName != pngname:
291 self.coverArtFileName = pngname
292 self["coverArt"].instance.setPixmapFromFile(self.coverArtFileName)
295 self.lefttimer = True
296 self.leftKeyTimer.start(1000)
299 self.righttimer = True
300 self.rightKeyTimer.start(1000)
304 self.leftKeyTimer.stop()
305 self.lefttimer = False
306 self[self.currList].pageUp()
307 self.updateCurrentInfo()
311 self.rightKeyTimer.stop()
312 self.righttimer = False
313 self[self.currList].pageDown()
314 self.updateCurrentInfo()
316 def leftTimerFire(self):
317 self.leftKeyTimer.stop()
318 self.lefttimer = False
319 self.switchToFileList()
321 def rightTimerFire(self):
322 self.rightKeyTimer.stop()
323 self.righttimer = False
324 self.switchToPlayList()
326 def switchToFileList(self):
327 self.currList = "filelist"
328 self.filelist.selectionEnabled(1)
329 self.playlist.selectionEnabled(0)
330 self.updateCurrentInfo()
332 def switchToPlayList(self):
333 if len(self.playlist) != 0:
334 self.currList = "playlist"
335 self.filelist.selectionEnabled(0)
336 self.playlist.selectionEnabled(1)
337 self.updateCurrentInfo()
340 self[self.currList].up()
341 self.updateCurrentInfo()
344 self[self.currList].down()
345 self.updateCurrentInfo()
347 def showAfterSeek(self):
350 def showAfterCuesheetOperation(self):
353 def hideAfterResume(self):
356 def getIdentifier(self, ref):
361 return text.split('/')[-1]
363 # FIXME: maybe this code can be optimized
364 def updateCurrentInfo(self):
366 if self.currList == "filelist":
367 idx = self.filelist.getSelectionIndex()
368 r = self.filelist.list[idx]
375 self.summaries.setText(text,1)
378 if idx < len(self.filelist.list):
379 r = self.filelist.list[idx]
383 self.summaries.setText(text,3)
385 self.summaries.setText(" ",3)
388 if idx < len(self.filelist.list):
389 r = self.filelist.list[idx]
393 self.summaries.setText(text,4)
395 self.summaries.setText(" ",4)
398 if not self.filelist.canDescent():
399 r = self.filelist.getServiceRef()
403 self["currenttext"].setText(os_path.basename(text))
405 if self.currList == "playlist":
406 t = self.playlist.getSelection()
409 #display current selected entry on LCD
410 text = self.getIdentifier(t)
411 self.summaries.setText(text,1)
412 self["currenttext"].setText(text)
413 idx = self.playlist.getSelectionIndex()
415 if idx < len(self.playlist):
416 currref = self.playlist.getServiceRefList()[idx]
417 text = self.getIdentifier(currref)
418 self.summaries.setText(text,3)
420 self.summaries.setText(" ",3)
423 if idx < len(self.playlist):
424 currref = self.playlist.getServiceRefList()[idx]
425 text = self.getIdentifier(currref)
426 self.summaries.setText(text,4)
428 self.summaries.setText(" ",4)
431 if self.currList == "filelist":
432 if self.filelist.canDescent():
433 self.filelist.descent()
434 self.updateCurrentInfo()
438 if self.currList == "playlist":
439 selection = self["playlist"].getSelection()
440 self.changeEntry(self.playlist.getSelectionIndex())
444 if self.currList == "filelist":
445 if self.filelist.canDescent():
446 menu.append((_("add directory to playlist"), "copydir"))
448 menu.append((_("add files to playlist"), "copyfiles"))
449 menu.append((_("switch to playlist"), "playlist"))
451 menu.append((_("switch to filelist"), "filelist"))
453 menu.append((_("shuffle playlist"), "shuffle"))
455 menu.append((_("delete"), "delete"))
456 menu.append((_("clear playlist"), "clear"))
457 menu.append((_("hide player"), "hide"));
458 menu.append((_("save playlist"), "saveplaylist"));
459 menu.append((_("load playlist"), "loadplaylist"));
460 menu.append((_("delete saved playlist"), "deleteplaylist"));
461 menu.append((_("repeat playlist"), "repeat"));
462 self.cdAudioTrackFiles = []
463 drivepath = harddiskmanager.getAutofsMountpoint(harddiskmanager.getCD())
464 if pathExists(drivepath):
465 from Components.Scanner import scanDevice
466 res = scanDevice(drivepath)
467 list = [ (r.description, r, res[r], self.session) for r in res ]
469 (desc, scanner, files, session) = list[0]
471 if file.mimetype == "audio/x-cda":
472 self.cdAudioTrackFiles.append(file.path)
473 if len(self.cdAudioTrackFiles):
474 menu.insert(0,(_("Play Audio-CD..."), "audiocd"))
475 self.session.openWithCallback(self.menuCallback, ChoiceBox, title="", list=menu)
477 def menuCallback(self, choice):
481 if choice[1] == "copydir":
482 self.copyDirectory(self.filelist.getSelection()[0])
483 elif choice[1] == "copyfiles":
485 self.playlist.clear()
486 self.copyDirectory(os_path.dirname(self.filelist.getSelection()[0].getPath()) + "/", recursive = False)
487 self.playServiceRefEntry(self.filelist.getServiceRef())
488 elif choice[1] == "playlist":
489 self.switchToPlayList()
490 elif choice[1] == "filelist":
491 self.switchToFileList()
492 elif choice[1] == "delete":
493 if self.playlist.getSelectionIndex() == self.playlist.getCurrentIndex():
496 elif choice[1] == "clear":
498 self.playlist.clear()
499 self.switchToFileList()
500 elif choice[1] == "hide":
502 elif choice[1] == "saveplaylist":
504 elif choice[1] == "loadplaylist":
506 elif choice[1] == "deleteplaylist":
507 self.delete_saved_playlist()
508 elif choice[1] == "shuffle":
509 self.playlist.PlayListShuffle()
510 elif choice[1] == "repeat":
511 if self.repeat == True:
513 self["repeat"].setPixmapNum(0)
516 self["repeat"].setPixmapNum(1)
517 elif choice[1] == "audiocd":
520 def playAudioCD(self):
521 from enigma import eServiceReference
522 from Plugins.Extensions.CDInfo.plugin import Query
523 self.playlist.clear()
524 self.savePlaylistOnExit = False
525 self.isAudioCD = True
526 for file in self.cdAudioTrackFiles:
527 ref = eServiceReference(4097, 0, file)
528 self.playlist.addFile(ref)
532 self.switchToPlayList()
534 def showEventInformation(self):
535 from Screens.EventView import EventViewSimple
536 from ServiceReference import ServiceReference
537 evt = self[self.currList].getCurrentEvent()
539 self.session.open(EventViewSimple, evt, ServiceReference(self.getCurrent()))
541 # also works on filelist (?)
542 def getCurrent(self):
543 return self["playlist"].getCurrent()
545 def deletePlaylistEntry(self):
546 if self.currList == "playlist":
547 if self.playlist.getSelectionIndex() == self.playlist.getCurrentIndex():
551 def skip_listbegin(self):
552 if self.currList == "filelist":
553 self.filelist.moveToIndex(0)
555 self.playlist.moveToIndex(0)
556 self.updateCurrentInfo()
558 def skip_listend(self):
559 if self.currList == "filelist":
560 idx = len(self.filelist.list)
561 self.filelist.moveToIndex(idx - 1)
563 self.playlist.moveToIndex(len(self.playlist)-1)
564 self.updateCurrentInfo()
566 def save_playlist(self):
567 self.session.openWithCallback(self.save_playlist2,InputBox, title=_("Please enter filename (empty = use current date)"),windowTitle = _("Save Playlist"))
569 def save_playlist2(self, name):
573 name = strftime("%y%m%d_%H%M%S")
575 self.playlistIOInternal.clear()
576 for x in self.playlist.list:
577 self.playlistIOInternal.addService(ServiceReference(x[0]))
578 self.playlistIOInternal.save(resolveFilename(SCOPE_PLAYLIST) + name)
580 def load_playlist(self):
582 playlistdir = resolveFilename(SCOPE_PLAYLIST)
584 for i in os_listdir(playlistdir):
585 listpath.append((i,playlistdir + i))
587 print "Error while scanning subdirs ",e
588 self.session.openWithCallback(self.PlaylistSelected, ChoiceBox, title=_("Please select a playlist..."), list = listpath)
590 def PlaylistSelected(self,path):
592 self.clear_playlist()
593 self.playlistIOInternal = PlaylistIOInternal()
594 list = self.playlistIOInternal.open(path[1])
597 self.playlist.addFile(x.ref)
598 self.playlist.updateList()
600 def delete_saved_playlist(self):
602 playlistdir = resolveFilename(SCOPE_PLAYLIST)
604 for i in os_listdir(playlistdir):
605 listpath.append((i,playlistdir + i))
607 print "Error while scanning subdirs ",e
608 self.session.openWithCallback(self.DeletePlaylistSelected, ChoiceBox, title=_("Please select a playlist to delete..."), list = listpath)
610 def DeletePlaylistSelected(self,path):
612 self.delname = path[1]
613 self.session.openWithCallback(self.deleteConfirmed, MessageBox, _("Do you really want to delete %s?") % (path[1]))
615 def deleteConfirmed(self, confirmed):
617 os_remove(self.delname)
619 def clear_playlist(self):
621 self.playlist.clear()
622 self.switchToFileList()
624 def copyDirectory(self, directory, recursive = True):
625 print "copyDirectory", directory
626 filelist = FileList(directory, useServiceRef = True, isTop = True)
628 for x in filelist.getFileList():
629 if x[0][1] == True: #isDir
631 self.copyDirectory(x[0][0])
633 self.playlist.addFile(x[0][0])
634 self.playlist.updateList()
637 if self.filelist.getServiceRef().type == 4098: # playlist
638 ServiceRef = self.filelist.getServiceRef()
639 extension = ServiceRef.getPath()[ServiceRef.getPath().rfind('.') + 1:]
640 print "extension:", extension
641 if self.playlistparsers.has_key(extension):
642 playlist = self.playlistparsers[extension]()
643 list = playlist.open(ServiceRef.getPath())
645 self.playlist.addFile(x.ref)
647 self.playlist.addFile(self.filelist.getServiceRef())
648 self.playlist.updateList()
649 if len(self.playlist) == 1:
652 def addPlaylistParser(self, parser, extension):
653 self.playlistparsers[extension] = parser
656 next = self.playlist.getCurrentIndex() + 1
657 if next < len(self.playlist):
658 self.changeEntry(next)
659 elif ( len(self.playlist) > 0 ) and ( self.repeat == True ):
663 def nextMarkOrEntry(self):
664 if not self.jumpPreviousNextMark(lambda x: x):
665 next = self.playlist.getCurrentIndex() + 1
666 if next < len(self.playlist):
667 self.changeEntry(next)
671 def previousMarkOrEntry(self):
672 if not self.jumpPreviousNextMark(lambda x: -x-5*90000, start=True):
673 next = self.playlist.getCurrentIndex() - 1
675 self.changeEntry(next)
677 def deleteEntry(self):
678 self.playlist.deleteFile(self.playlist.getSelectionIndex())
679 self.playlist.updateList()
680 if len(self.playlist) == 0:
681 self.switchToFileList()
683 def changeEntry(self, index):
684 self.playlist.setCurrentPlaying(index)
687 def playServiceRefEntry(self, serviceref):
688 serviceRefList = self.playlist.getServiceRefList()
689 for count in range(len(serviceRefList)):
690 if serviceRefList[count] == serviceref:
691 self.changeEntry(count)
694 def xplayEntry(self):
695 if self.currList == "playlist":
699 self.playlist.clear()
700 sel = self.filelist.getSelection()
702 if sel[1]: # can descent
703 # add directory to playlist
704 self.copyDirectory(sel[0])
706 # add files to playlist
707 self.copyDirectory(os_path.dirname(sel[0].getPath()) + "/", recursive = False)
708 if len(self.playlist) > 0:
712 if len(self.playlist.getServiceRefList()):
713 needsInfoUpdate = False
714 currref = self.playlist.getServiceRefList()[self.playlist.getCurrentIndex()]
715 if self.session.nav.getCurrentlyPlayingServiceReference() is None or currref != self.session.nav.getCurrentlyPlayingServiceReference():
716 self.session.nav.playService(self.playlist.getServiceRefList()[self.playlist.getCurrentIndex()])
717 info = eServiceCenter.getInstance().info(currref)
718 description = info and info.getInfoString(currref, iServiceInformation.sDescription) or ""
719 self["title"].setText(description)
720 # display just playing musik on LCD
721 idx = self.playlist.getCurrentIndex()
722 currref = self.playlist.getServiceRefList()[idx]
723 text = self.getIdentifier(currref)
725 ext = text[-4:].lower()
727 # FIXME: the information if the service contains video (and we should hide our window) should com from the service instead
728 if ext not in [".mp3", ".wav", ".ogg", "flac"] and not self.isAudioCD:
731 needsInfoUpdate = True
732 self.summaries.setText(text,1)
734 # get the next two entries
736 if idx < len(self.playlist):
737 currref = self.playlist.getServiceRefList()[idx]
738 text = self.getIdentifier(currref)
739 self.summaries.setText(text,3)
741 self.summaries.setText(" ",3)
744 if idx < len(self.playlist):
745 currref = self.playlist.getServiceRefList()[idx]
746 text = self.getIdentifier(currref)
747 self.summaries.setText(text,4)
749 self.summaries.setText(" ",4)
751 idx = self.playlist.getCurrentIndex()
752 currref = self.playlist.getServiceRefList()[idx]
753 text = currref.getPath()
754 ext = text[-4:].lower()
755 if ext not in [".mp3", ".wav", ".ogg", "flac"] and not self.isAudioCD:
758 needsInfoUpdate = True
760 self.unPauseService()
761 if needsInfoUpdate == True:
762 self.updateCoverArtPixmap(currref.getPath())
764 pngname = self["coverArt"].default_pixmap
765 self.coverArtFileName = pngname
766 self["coverArt"].instance.setPixmapFromFile(self.coverArtFileName)
767 self.readTitleInformation()
769 def updatedSeekState(self):
770 if self.seekstate == self.SEEK_STATE_PAUSE:
771 self.playlist.pauseFile()
772 elif self.seekstate == self.SEEK_STATE_PLAY:
773 self.playlist.playFile()
774 elif self.isStateForward(self.seekstate):
775 self.playlist.forwardFile()
776 elif self.isStateBackward(self.seekstate):
777 self.playlist.rewindFile()
779 def pauseEntry(self):
781 if self.seekstate == self.SEEK_STATE_PAUSE:
787 self.playlist.stopFile()
788 self.session.nav.playService(None)
789 self.updateMusicInformation(clear=True)
792 def unPauseService(self):
793 self.setSeekState(self.SEEK_STATE_PLAY)
795 def subtitleSelection(self):
796 from Screens.Subtitles import Subtitles
797 self.session.open(Subtitles)
799 class MediaPlayerLCDScreen(Screen):
801 <screen position="0,0" size="132,64" title="LCD Text">
802 <widget name="text1" position="4,0" size="132,35" font="Regular;16"/>
803 <widget name="text3" position="4,36" size="132,14" font="Regular;10"/>
804 <widget name="text4" position="4,49" size="132,14" font="Regular;10"/>
807 def __init__(self, session, parent):
808 Screen.__init__(self, session)
809 self["text1"] = Label("Mediaplayer")
810 self["text3"] = Label("")
811 self["text4"] = Label("")
813 def setText(self, text, line):
814 print "lcd set text:", text, line
816 if text[-4:] == ".mp3":
819 text = text + textleer*10
821 self["text1"].setText(text)
823 self["text3"].setText(text)
825 self["text4"].setText(text)
827 def main(session, **kwargs):
828 session.open(MediaPlayer)
830 def menu(menuid, **kwargs):
831 if menuid == "mainmenu":
832 return [(_("Media player"), main, "media_player", 45)]
835 def filescan_open(list, session, **kwargs):
836 from enigma import eServiceReference
838 mp = session.open(MediaPlayer)
840 mp.savePlaylistOnExit = False
843 if file.mimetype == "video/MP2T":
847 ref = eServiceReference(stype, 0, file.path)
848 mp.playlist.addFile(ref)
851 mp.switchToPlayList()
853 def audioCD_open(list, session, **kwargs):
854 from enigma import eServiceReference
856 mp = session.open(MediaPlayer)
857 mp.cdAudioTrackFiles = []
859 mp.cdAudioTrackFiles.append(file.path)
862 def filescan(**kwargs):
863 from Components.Scanner import Scanner, ScanPath
865 Scanner(mimetypes = ["video/mpeg", "video/MP2T", "video/x-msvideo"],
868 ScanPath(path = "", with_subdirs = False),
871 description = "View Movies...",
872 openfnc = filescan_open,
874 Scanner(mimetypes = ["video/x-vcd"],
877 ScanPath(path = "mpegav", with_subdirs = False),
878 ScanPath(path = "MPEGAV", with_subdirs = False),
881 description = "View Video CD...",
882 openfnc = filescan_open,
884 Scanner(mimetypes = ["audio/mpeg", "audio/x-wav", "application/ogg", "audio/x-flac"],
887 ScanPath(path = "", with_subdirs = False),
890 description = "Play Music...",
891 openfnc = filescan_open,
894 from Plugins.Extensions.CDInfo.plugin import Query
896 Scanner(mimetypes = ["audio/x-cda"],
899 ScanPath(path = "", with_subdirs = False),
902 description = "Play Audio-CD...",
903 openfnc = audioCD_open,
909 from Plugins.Plugin import PluginDescriptor
910 def Plugins(**kwargs):
912 PluginDescriptor(name = "MediaPlayer", description = "Play back media files", where = PluginDescriptor.WHERE_MENU, fnc = menu),
913 PluginDescriptor(name = "MediaPlayer", where = PluginDescriptor.WHERE_FILESCAN, fnc = filescan)