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
18 from ServiceReference import ServiceReference
19 from Screens.ChoiceBox import ChoiceBox
20 from Screens.HelpMenu import HelpableScreen
23 class MyPlayList(PlayList):
25 PlayList.__init__(self)
27 def PlayListShuffle(self):
28 random.shuffle(self.list)
29 self.l.setList(self.list)
31 self.oldCurrPlaying = -1
33 class MediaPixmap(Pixmap):
34 def applySkin(self, desktop, screen):
35 self.default_pixmap = None
36 if self.skinAttributes is not None:
37 for (attrib, value) in self.skinAttributes:
38 if attrib == "pixmap":
39 self.default_pixmap = value
41 if self.default_pixmap is None:
42 self.default_pixmap = resolveFilename(SCOPE_SKIN_IMAGE, "skin_default/no_coverArt.png")
43 return Pixmap.applySkin(self, desktop, screen)
45 class MediaPlayer(Screen, InfoBarBase, InfoBarSeek, InfoBarAudioSelection, InfoBarCueSheetSupport, InfoBarNotifications, HelpableScreen):
47 ENABLE_RESUME_SUPPORT = True
49 def __init__(self, session, args = None):
50 Screen.__init__(self, session)
51 InfoBarAudioSelection.__init__(self)
52 InfoBarCueSheetSupport.__init__(self, actionmap = "MediaPlayerCueSheetActions")
53 InfoBarNotifications.__init__(self)
54 InfoBarBase.__init__(self)
55 HelpableScreen.__init__(self)
57 self.oldService = self.session.nav.getCurrentlyPlayingServiceReference()
58 self.session.nav.stopService()
60 self.playlistparsers = {}
61 self.addPlaylistParser(PlaylistIOM3U, "m3u")
62 self.addPlaylistParser(PlaylistIOPLS, "pls")
63 self.addPlaylistParser(PlaylistIOInternal, "e2pls")
65 # 'None' is magic to start at the list of mountpoints
66 self.filelist = FileList(None, matchingPattern = "(?i)^.*\.(mp3|ogg|ts|wav|wave|m3u|pls|e2pls|mpg|vob|avi)", useServiceRef = True, additionalExtensions = "4098:m3u 4098:e2pls 4098:pls")
67 self["filelist"] = self.filelist
69 self.playlist = MyPlayList()
70 #self.playlist = PlayList()
71 self.is_closing = False
73 self["playlist"] = self.playlist
75 self["PositionGauge"] = ServicePositionGauge(self.session.nav)
77 self["currenttext"] = Label("")
79 self["artisttext"] = Label(_("Artist:"))
80 self["artist"] = Label("")
81 self["titletext"] = Label(_("Title:"))
82 self["title"] = Label("")
83 self["albumtext"] = Label(_("Album:"))
84 self["album"] = Label("")
85 self["yeartext"] = Label(_("Year:"))
86 self["year"] = Label("")
87 self["genretext"] = Label(_("Genre:"))
88 self["genre"] = Label("")
89 self["coverArt"] = MediaPixmap()
90 self["repeat"] = MultiPixmap()
93 self.seek_target = None
95 class MoviePlayerActionMap(NumberActionMap):
96 def __init__(self, player, contexts = [ ], actions = { }, prio=0):
97 NumberActionMap.__init__(self, contexts, actions, prio)
100 def action(self, contexts, action):
102 return NumberActionMap.action(self, contexts, action)
105 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
107 "ok": (self.ok, _("add file to playlist")),
108 "cancel": (self.exit, _("exit mediaplayer")),
111 self["MediaPlayerActions"] = HelpableActionMap(self, "MediaPlayerActions",
113 "play": (self.xplayEntry, _("play entry")),
114 "pause": (self.pauseEntry, _("pause")),
115 "stop": (self.stopEntry, _("stop entry")),
116 "previous": (self.previousMarkOrEntry, _("play from previous mark or playlist entry")),
117 "next": (self.nextMarkOrEntry, _("play from next mark or playlist entry")),
118 "menu": (self.showMenu, _("menu")),
119 "skipListbegin": (self.skip_listbegin, _("jump to listbegin")),
120 "skipListend": (self.skip_listend, _("jump to listend")),
121 "prevBouquet": (self.switchToPlayList, _("switch to playlist")),
122 "nextBouquet": (self.switchToFileList, _("switch to filelist")),
123 "delete": (self.deletePlaylistEntry, _("delete playlist entry")),
124 "shift_stop": (self.clear_playlist, _("clear playlist")),
125 "shift_record": (self.playlist.PlayListShuffle, _("shuffle playlist")),
128 self["InfobarEPGActions"] = HelpableActionMap(self, "InfobarEPGActions",
130 "showEventInfo": (self.showEventInformation, _("show event details")),
133 self["actions"] = MoviePlayerActionMap(self, ["DirectionActions"],
135 "right": self.rightDown,
136 "rightRepeated": self.doNothing,
137 "rightUp": self.rightUp,
138 "left": self.leftDown,
139 "leftRepeated": self.doNothing,
140 "leftUp": self.leftUp,
143 "upRepeated": self.up,
144 "upUp": self.doNothing,
146 "downRepeated": self.down,
147 "downUp": self.doNothing,
150 InfoBarSeek.__init__(self, actionmap = "MediaPlayerSeekActions")
152 self.onClose.append(self.delMPTimer)
153 self.onClose.append(self.__onClose)
155 self.righttimer = False
156 self.rightKeyTimer = eTimer()
157 self.rightKeyTimer.callback.append(self.rightTimerFire)
159 self.lefttimer = False
160 self.leftKeyTimer = eTimer()
161 self.leftKeyTimer.callback.append(self.leftTimerFire)
163 self.currList = "filelist"
165 self.coverArtFileName = ""
166 self.isAudioCD = False
167 self.AudioCD_albuminfo = {}
168 self.savePlaylistOnExit = True
170 self.playlistIOInternal = PlaylistIOInternal()
171 list = self.playlistIOInternal.open(resolveFilename(SCOPE_CONFIG, "playlist.e2pls"))
174 self.playlist.addFile(x.ref)
175 self.playlist.updateList()
177 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
179 iPlayableService.evUpdatedInfo: self.__evUpdatedInfo
185 def createSummary(self):
186 return MediaPlayerLCDScreen
189 self.session.openWithCallback(self.exitCB, MessageBox, _("Do you really want to exit?"), timeout=5)
191 def exitCB(self, answer):
193 self.playlistIOInternal.clear()
194 for x in self.playlist.list:
195 self.playlistIOInternal.addService(ServiceReference(x[0]))
196 if self.savePlaylistOnExit:
197 self.playlistIOInternal.save(resolveFilename(SCOPE_CONFIG, "playlist.e2pls"))
200 def checkSkipShowHideLock(self):
201 self.updatedSeekState()
203 def doEofInternal(self, playing):
210 self.session.nav.playService(self.oldService)
212 def __evUpdatedInfo(self):
213 currPlay = self.session.nav.getCurrentService()
214 currenttitle = currPlay.info().getInfo(iServiceInformation.sCurrentTitle)
215 totaltitles = currPlay.info().getInfo(iServiceInformation.sTotalTitles)
216 sTitle = currPlay.info().getInfoString(iServiceInformation.sTitle)
217 print "[__evUpdatedInfo] title %d of %d (%s)" % (currenttitle, totaltitles, sTitle)
218 self.readTitleInformation()
220 def delMPTimer(self):
221 del self.rightKeyTimer
222 del self.leftKeyTimer
224 def readTitleInformation(self):
225 currPlay = self.session.nav.getCurrentService()
226 if currPlay is not None:
227 sTitle = currPlay.info().getInfoString(iServiceInformation.sTitle)
228 sAlbum = currPlay.info().getInfoString(iServiceInformation.sAlbum)
229 sGenre = currPlay.info().getInfoString(iServiceInformation.sGenre)
230 sArtist = currPlay.info().getInfoString(iServiceInformation.sArtist)
234 if not self.isAudioCD:
235 sTitle = currPlay.info().getName().split('/')[-1]
237 sTitle = self.playlist.getServiceRefList()[self.playlist.getCurrentIndex()].getName()
239 if self.AudioCD_albuminfo:
240 if sAlbum == "" and "title" in self.AudioCD_albuminfo:
241 sAlbum = self.AudioCD_albuminfo["title"]
242 if sGenre == "" and "genre" in self.AudioCD_albuminfo:
243 sGenre = self.AudioCD_albuminfo["genre"]
244 if sArtist == "" and "artist" in self.AudioCD_albuminfo:
245 sArtist = self.AudioCD_albuminfo["artist"]
246 if "year" in self.AudioCD_albuminfo:
247 sYear = self.AudioCD_albuminfo["year"]
249 self.updateMusicInformation( sArtist, sTitle, sAlbum, sYear, sGenre, clear = True )
251 self.updateMusicInformation()
253 def updateMusicInformation(self, artist = "", title = "", album = "", year = "", genre = "", clear = False):
254 self.updateSingleMusicInformation("artist", artist, clear)
255 self.updateSingleMusicInformation("title", title, clear)
256 self.updateSingleMusicInformation("album", album, clear)
257 self.updateSingleMusicInformation("year", year, clear)
258 self.updateSingleMusicInformation("genre", genre, clear)
260 def updateSingleMusicInformation(self, name, info, clear):
261 if info != "" or clear:
262 if self[name].getText() != info:
263 self[name].setText(info)
265 def updateCoverArtPixmap(self, path):
266 while not path.endswith("/"):
268 pngname = path + "folder.png"
270 if not os_path.exists(pngname):
271 pngname = self["coverArt"].default_pixmap
272 if self.coverArtFileName != pngname:
273 self.coverArtFileName = pngname
274 self["coverArt"].instance.setPixmapFromFile(self.coverArtFileName)
277 self.lefttimer = True
278 self.leftKeyTimer.start(1000)
281 self.righttimer = True
282 self.rightKeyTimer.start(1000)
286 self.leftKeyTimer.stop()
287 self.lefttimer = False
288 self[self.currList].pageUp()
289 self.updateCurrentInfo()
293 self.rightKeyTimer.stop()
294 self.righttimer = False
295 self[self.currList].pageDown()
296 self.updateCurrentInfo()
298 def leftTimerFire(self):
299 self.leftKeyTimer.stop()
300 self.lefttimer = False
301 self.switchToFileList()
303 def rightTimerFire(self):
304 self.rightKeyTimer.stop()
305 self.righttimer = False
306 self.switchToPlayList()
308 def switchToFileList(self):
309 self.currList = "filelist"
310 self.filelist.selectionEnabled(1)
311 self.playlist.selectionEnabled(0)
312 self.updateCurrentInfo()
314 def switchToPlayList(self):
315 if len(self.playlist) != 0:
316 self.currList = "playlist"
317 self.filelist.selectionEnabled(0)
318 self.playlist.selectionEnabled(1)
319 self.updateCurrentInfo()
322 self[self.currList].up()
323 self.updateCurrentInfo()
326 self[self.currList].down()
327 self.updateCurrentInfo()
329 def showAfterSeek(self):
332 def showAfterCuesheetOperation(self):
335 def hideAfterResume(self):
338 def getIdentifier(self, ref):
343 return text.split('/')[-1]
345 # FIXME: maybe this code can be optimized
346 def updateCurrentInfo(self):
348 if self.currList == "filelist":
349 idx = self.filelist.getSelectionIndex()
350 r = self.filelist.list[idx]
357 self.summaries.setText(text,1)
360 if idx < len(self.filelist.list):
361 r = self.filelist.list[idx]
365 self.summaries.setText(text,3)
367 self.summaries.setText(" ",3)
370 if idx < len(self.filelist.list):
371 r = self.filelist.list[idx]
375 self.summaries.setText(text,4)
377 self.summaries.setText(" ",4)
380 if not self.filelist.canDescent():
381 r = self.filelist.getServiceRef()
385 self["currenttext"].setText(os_path.basename(text))
387 if self.currList == "playlist":
388 t = self.playlist.getSelection()
391 #display current selected entry on LCD
392 text = self.getIdentifier(t)
393 self.summaries.setText(text,1)
394 self["currenttext"].setText(text)
395 idx = self.playlist.getSelectionIndex()
397 if idx < len(self.playlist):
398 currref = self.playlist.getServiceRefList()[idx]
399 text = self.getIdentifier(currref)
400 self.summaries.setText(text,3)
402 self.summaries.setText(" ",3)
405 if idx < len(self.playlist):
406 currref = self.playlist.getServiceRefList()[idx]
407 text = self.getIdentifier(currref)
408 self.summaries.setText(text,4)
410 self.summaries.setText(" ",4)
413 if self.currList == "filelist":
414 if self.filelist.canDescent():
415 self.filelist.descent()
416 self.updateCurrentInfo()
420 if self.currList == "playlist":
421 selection = self["playlist"].getSelection()
422 self.changeEntry(self.playlist.getSelectionIndex())
426 if self.currList == "filelist":
427 if self.filelist.canDescent():
428 menu.append((_("add directory to playlist"), "copydir"))
430 menu.append((_("add files to playlist"), "copyfiles"))
431 menu.append((_("switch to playlist"), "playlist"))
433 menu.append((_("switch to filelist"), "filelist"))
435 menu.append((_("shuffle playlist"), "shuffle"))
437 menu.append((_("delete"), "delete"))
438 menu.append((_("clear playlist"), "clear"))
439 menu.append((_("hide player"), "hide"));
440 menu.append((_("save playlist"), "saveplaylist"));
441 menu.append((_("load playlist"), "loadplaylist"));
442 menu.append((_("delete saved playlist"), "deleteplaylist"));
443 menu.append((_("repeat playlist"), "repeat"));
444 self.session.openWithCallback(self.menuCallback, ChoiceBox, title="", list=menu)
446 def menuCallback(self, choice):
450 if choice[1] == "copydir":
451 self.copyDirectory(self.filelist.getSelection()[0])
452 elif choice[1] == "copyfiles":
454 self.playlist.clear()
455 self.copyDirectory(os_path.dirname(self.filelist.getSelection()[0].getPath()) + "/", recursive = False)
456 self.playServiceRefEntry(self.filelist.getServiceRef())
457 elif choice[1] == "playlist":
458 self.switchToPlayList()
459 elif choice[1] == "filelist":
460 self.switchToFileList()
461 elif choice[1] == "delete":
462 if self.playlist.getSelectionIndex() == self.playlist.getCurrentIndex():
465 elif choice[1] == "clear":
467 self.playlist.clear()
468 self.switchToFileList()
469 elif choice[1] == "hide":
471 elif choice[1] == "saveplaylist":
473 elif choice[1] == "loadplaylist":
475 elif choice[1] == "deleteplaylist":
476 self.delete_saved_playlist()
477 elif choice[1] == "shuffle":
478 self.playlist.PlayListShuffle()
479 elif choice[1] == "repeat":
480 if self.repeat == True:
482 self["repeat"].setPixmapNum(0)
485 self["repeat"].setPixmapNum(1)
487 def showEventInformation(self):
488 from Screens.EventView import EventViewSimple
489 from ServiceReference import ServiceReference
490 evt = self[self.currList].getCurrentEvent()
492 self.session.open(EventViewSimple, evt, ServiceReference(self.getCurrent()))
494 # also works on filelist (?)
495 def getCurrent(self):
496 return self["playlist"].getCurrent()
498 def deletePlaylistEntry(self):
499 if self.currList == "playlist":
500 if self.playlist.getSelectionIndex() == self.playlist.getCurrentIndex():
504 def skip_listbegin(self):
505 if self.currList == "filelist":
506 self.filelist.moveToIndex(0)
508 self.playlist.moveToIndex(0)
509 self.updateCurrentInfo()
511 def skip_listend(self):
512 if self.currList == "filelist":
513 idx = len(self.filelist.list)
514 self.filelist.moveToIndex(idx - 1)
516 self.playlist.moveToIndex(len(self.playlist)-1)
517 self.updateCurrentInfo()
519 def save_playlist(self):
520 self.session.openWithCallback(self.save_playlist2,InputBox, title=_("Please enter filename (empty = use current date)"),windowTitle = _("Save Playlist"))
522 def save_playlist2(self, name):
526 name = strftime("%y%m%d_%H%M%S")
528 self.playlistIOInternal.clear()
529 for x in self.playlist.list:
530 self.playlistIOInternal.addService(ServiceReference(x[0]))
531 self.playlistIOInternal.save(resolveFilename(SCOPE_PLAYLIST) + name)
533 def load_playlist(self):
535 playlistdir = resolveFilename(SCOPE_PLAYLIST)
537 for i in os_listdir(playlistdir):
538 listpath.append((i,playlistdir + i))
540 print "Error while scanning subdirs ",e
541 self.session.openWithCallback(self.PlaylistSelected, ChoiceBox, title=_("Please select a playlist..."), list = listpath)
543 def PlaylistSelected(self,path):
545 self.clear_playlist()
546 self.playlistIOInternal = PlaylistIOInternal()
547 list = self.playlistIOInternal.open(path[1])
550 self.playlist.addFile(x.ref)
551 self.playlist.updateList()
553 def delete_saved_playlist(self):
555 playlistdir = resolveFilename(SCOPE_PLAYLIST)
557 for i in os_listdir(playlistdir):
558 listpath.append((i,playlistdir + i))
560 print "Error while scanning subdirs ",e
561 self.session.openWithCallback(self.DeletePlaylistSelected, ChoiceBox, title=_("Please select a playlist to delete..."), list = listpath)
563 def DeletePlaylistSelected(self,path):
565 self.delname = path[1]
566 self.session.openWithCallback(self.deleteConfirmed, MessageBox, _("Do you really want to delete %s?") % (path[1]))
568 def deleteConfirmed(self, confirmed):
570 os_remove(self.delname)
572 def clear_playlist(self):
574 self.playlist.clear()
575 self.switchToFileList()
577 def copyDirectory(self, directory, recursive = True):
578 print "copyDirectory", directory
579 filelist = FileList(directory, useServiceRef = True, isTop = True)
581 for x in filelist.getFileList():
582 if x[0][1] == True: #isDir
584 self.copyDirectory(x[0][0])
586 self.playlist.addFile(x[0][0])
587 self.playlist.updateList()
590 if self.filelist.getServiceRef().type == 4098: # playlist
591 ServiceRef = self.filelist.getServiceRef()
592 extension = ServiceRef.getPath()[ServiceRef.getPath().rfind('.') + 1:]
593 print "extension:", extension
594 if self.playlistparsers.has_key(extension):
595 playlist = self.playlistparsers[extension]()
596 list = playlist.open(ServiceRef.getPath())
598 self.playlist.addFile(x.ref)
600 self.playlist.addFile(self.filelist.getServiceRef())
601 self.playlist.updateList()
602 if len(self.playlist) == 1:
605 def addPlaylistParser(self, parser, extension):
606 self.playlistparsers[extension] = parser
609 next = self.playlist.getCurrentIndex() + 1
610 if next < len(self.playlist):
611 self.changeEntry(next)
612 elif ( len(self.playlist) > 0 ) and ( self.repeat == True ):
616 def nextMarkOrEntry(self):
617 if not self.jumpPreviousNextMark(lambda x: x):
618 next = self.playlist.getCurrentIndex() + 1
619 if next < len(self.playlist):
620 self.changeEntry(next)
624 def previousMarkOrEntry(self):
625 if not self.jumpPreviousNextMark(lambda x: -x-5*90000, start=True):
626 next = self.playlist.getCurrentIndex() - 1
628 self.changeEntry(next)
630 def deleteEntry(self):
631 self.playlist.deleteFile(self.playlist.getSelectionIndex())
632 self.playlist.updateList()
633 if len(self.playlist) == 0:
634 self.switchToFileList()
636 def changeEntry(self, index):
637 self.playlist.setCurrentPlaying(index)
640 def playServiceRefEntry(self, serviceref):
641 serviceRefList = self.playlist.getServiceRefList()
642 for count in range(len(serviceRefList)):
643 if serviceRefList[count] == serviceref:
644 self.changeEntry(count)
647 def xplayEntry(self):
648 if self.currList == "playlist":
652 self.playlist.clear()
653 sel = self.filelist.getSelection()
655 if sel[1]: # can descent
656 # add directory to playlist
657 self.copyDirectory(sel[0])
659 # add files to playlist
660 self.copyDirectory(os_path.dirname(sel[0].getPath()) + "/", recursive = False)
661 if len(self.playlist) > 0:
665 if len(self.playlist.getServiceRefList()):
666 needsInfoUpdate = False
667 currref = self.playlist.getServiceRefList()[self.playlist.getCurrentIndex()]
668 if self.session.nav.getCurrentlyPlayingServiceReference() is None or currref != self.session.nav.getCurrentlyPlayingServiceReference():
669 self.session.nav.playService(self.playlist.getServiceRefList()[self.playlist.getCurrentIndex()])
670 info = eServiceCenter.getInstance().info(currref)
671 description = info and info.getInfoString(currref, iServiceInformation.sDescription) or ""
672 self["title"].setText(description)
673 # display just playing musik on LCD
674 idx = self.playlist.getCurrentIndex()
675 currref = self.playlist.getServiceRefList()[idx]
676 text = self.getIdentifier(currref)
678 ext = text[-3:].lower()
680 # FIXME: the information if the service contains video (and we should hide our window) should com from the service instead
681 if ext not in ["mp3", "wav", "ogg"] and not self.isAudioCD:
684 needsInfoUpdate = True
685 self.summaries.setText(text,1)
687 # get the next two entries
689 if idx < len(self.playlist):
690 currref = self.playlist.getServiceRefList()[idx]
691 text = self.getIdentifier(currref)
692 self.summaries.setText(text,3)
694 self.summaries.setText(" ",3)
697 if idx < len(self.playlist):
698 currref = self.playlist.getServiceRefList()[idx]
699 text = self.getIdentifier(currref)
700 self.summaries.setText(text,4)
702 self.summaries.setText(" ",4)
704 idx = self.playlist.getCurrentIndex()
705 currref = self.playlist.getServiceRefList()[idx]
706 text = currref.getPath()
707 ext = text[-3:].lower()
708 if ext not in ["mp3", "wav", "ogg"] and not self.isAudioCD:
711 needsInfoUpdate = True
713 self.unPauseService()
714 if needsInfoUpdate == True:
715 self.updateCoverArtPixmap(currref.getPath())
717 pngname = self["coverArt"].default_pixmap
718 self.coverArtFileName = pngname
719 self["coverArt"].instance.setPixmapFromFile(self.coverArtFileName)
720 self.readTitleInformation()
722 def updatedSeekState(self):
723 if self.seekstate == self.SEEK_STATE_PAUSE:
724 self.playlist.pauseFile()
725 elif self.seekstate == self.SEEK_STATE_PLAY:
726 self.playlist.playFile()
727 elif self.isStateForward(self.seekstate):
728 self.playlist.forwardFile()
729 elif self.isStateBackward(self.seekstate):
730 self.playlist.rewindFile()
732 def pauseEntry(self):
737 self.playlist.stopFile()
738 self.session.nav.playService(None)
739 self.updateMusicInformation(clear=True)
742 def unPauseService(self):
743 self.setSeekState(self.SEEK_STATE_PLAY)
745 class MediaPlayerLCDScreen(Screen):
747 <screen position="0,0" size="132,64" title="LCD Text">
748 <widget name="text1" position="4,0" size="132,35" font="Regular;16"/>
749 <widget name="text3" position="4,36" size="132,14" font="Regular;10"/>
750 <widget name="text4" position="4,49" size="132,14" font="Regular;10"/>
753 def __init__(self, session, parent):
754 Screen.__init__(self, session)
755 self["text1"] = Label("Mediaplayer")
756 self["text3"] = Label("")
757 self["text4"] = Label("")
759 def setText(self, text, line):
760 print "lcd set text:", text, line
762 if text[-4:] == ".mp3":
765 text = text + textleer*10
767 self["text1"].setText(text)
769 self["text3"].setText(text)
771 self["text4"].setText(text)
773 def main(session, **kwargs):
774 session.open(MediaPlayer)
776 def menu(menuid, **kwargs):
777 if menuid == "mainmenu":
778 return [(_("Media player"), main, "media_player", 45)]
781 def filescan_open(list, session, **kwargs):
782 from enigma import eServiceReference
784 mp = session.open(MediaPlayer)
786 mp.savePlaylistOnExit = False
789 if file.mimetype.startswith("video"):
793 ref = eServiceReference(stype, 0, file.path)
794 mp.playlist.addFile(ref)
797 mp.switchToPlayList()
799 def audioCD_open(list, session, **kwargs):
800 from enigma import eServiceReference
802 mp = session.open(MediaPlayer)
805 mp.savePlaylistOnExit = False
809 ref = eServiceReference(4097, 0, file.path)
810 mp.playlist.addFile(ref)
811 from Plugins.Extensions.CDInfo.plugin import Query
816 mp.switchToPlayList()
818 def filescan(**kwargs):
819 from Components.Scanner import Scanner, ScanPath
821 Scanner(mimetypes = ["video/mpeg", "video/MP2T", "video/x-msvideo"],
824 ScanPath(path = "", with_subdirs = False),
827 description = "View Movies...",
828 openfnc = filescan_open,
830 Scanner(mimetypes = ["audio/mpeg", "audio/x-wav", "application/ogg"],
833 ScanPath(path = "", with_subdirs = False),
836 description = "Play Music...",
837 openfnc = filescan_open,
840 from Plugins.Extensions.CDInfo.plugin import Query
841 mediatypes.insert(0,Scanner(mimetypes = ["audio/x-cda", "audio/x-wav"],
844 ScanPath(path = "", with_subdirs = False),
847 description = "Play Audio-CD...",
848 openfnc = audioCD_open,
854 from Plugins.Plugin import PluginDescriptor
855 def Plugins(**kwargs):
857 PluginDescriptor(name = "MediaPlayer", description = "Play back media files", where = PluginDescriptor.WHERE_MENU, fnc = menu),
858 PluginDescriptor(name = "MediaPlayer", where = PluginDescriptor.WHERE_FILESCAN, fnc = filescan)