1 from os import path as os_path, remove as os_remove, listdir as os_listdir, system
2 from enigma import eTimer, iPlayableService, iServiceInformation, eServiceReference, iServiceKeys, getDesktop
3 from Screens.Screen import Screen
4 from Screens.MessageBox import MessageBox
5 from Screens.ChoiceBox import ChoiceBox
6 from Screens.HelpMenu import HelpableScreen
7 from Screens.InfoBarGenerics import InfoBarSeek, InfoBarPVRState, InfoBarCueSheetSupport, InfoBarShowHide, InfoBarNotifications
8 from Components.ActionMap import ActionMap, NumberActionMap, HelpableActionMap
9 from Components.Label import Label
10 from Components.Sources.StaticText import StaticText
11 from Components.Pixmap import Pixmap
12 from Components.FileList import FileList
13 from Components.MenuList import MenuList
14 from Components.ServiceEventTracker import ServiceEventTracker, InfoBarBase
15 from Components.config import config
16 from Tools.Directories import pathExists, fileExists
17 from Components.Harddisk import harddiskmanager
19 import servicedvd # load c++ part of dvd player plugin
23 class FileBrowser(Screen):
25 def __init__(self, session, dvd_filelist = [ ]):
26 Screen.__init__(self, session)
28 # for the skin: first try FileBrowser_DVDPlayer, then FileBrowser, this allows individual skinning
29 self.skinName = ["FileBrowser_DVDPlayer", "FileBrowser" ]
31 self.dvd_filelist = dvd_filelist
33 self["filelist"] = MenuList(self.dvd_filelist)
36 if lastpath is not None:
37 currDir = lastpath + "/"
39 currDir = "/media/dvd/"
40 if not pathExists(currDir):
42 if lastpath == "": # 'None' is magic to start at the list of mountpoints
45 inhibitDirs = ["/bin", "/boot", "/dev", "/etc", "/home", "/lib", "/proc", "/sbin", "/share", "/sys", "/tmp", "/usr", "/var"]
46 self.filelist = FileList(currDir, matchingPattern = "(?i)^.*\.(iso)", useServiceRef = True)
47 self["filelist"] = self.filelist
49 self["FilelistActions"] = ActionMap(["SetupActions"],
55 self["key_red"] = StaticText(_("Cancel"))
56 self["key_green"] = StaticText(_("OK"))
57 self.onLayoutFinish.append(self.layoutFinished)
59 def layoutFinished(self):
60 self.setTitle(_("DVD File Browser"))
63 if len(self.dvd_filelist):
64 print "OK " + self["filelist"].getCurrent()
65 self.close(self["filelist"].getCurrent())
68 filename = self["filelist"].getFilename()
69 if filename is not None:
70 if filename.upper().endswith("VIDEO_TS/"):
71 print "dvd structure found, trying to open..."
72 dvdpath = filename[0:-9]
73 lastpath = (dvdpath.rstrip("/").rsplit("/",1))[0]
74 print "lastpath video_ts/=", lastpath
77 if self["filelist"].canDescent(): # isDir
78 self["filelist"].descent()
79 pathname = self["filelist"].getCurrentDirectory() or ""
80 if fileExists(pathname+"VIDEO_TS.IFO"):
81 print "dvd structure found, trying to open..."
82 lastpath = (pathname.rstrip("/").rsplit("/",1))[0]
83 print "lastpath video_ts.ifo=", lastpath
85 if fileExists(pathname+"VIDEO_TS/VIDEO_TS.IFO"):
86 print "dvd structure found, trying to open..."
87 lastpath = (pathname.rstrip("/").rsplit("/",1))[0]
88 print "lastpath video_ts.ifo=", lastpath
89 pathname += "VIDEO_TS"
92 lastpath = filename[0:filename.rfind("/")]
93 print "lastpath directory=", lastpath
99 class DVDSummary(Screen):
101 """<screen name="DVDSummary" position="0,0" size="132,64" id="1">
102 <widget source="session.CurrentService" render="Label" position="5,4" size="120,28" font="Regular;12" transparent="1" >
103 <convert type="ServiceName">Name</convert>
105 <widget name="DVDPlayer" position="5,30" size="66,16" font="Regular;11" transparent="1" />
106 <widget name="Chapter" position="72,30" size="54,16" font="Regular;12" transparent="1" halign="right" />
107 <widget source="session.CurrentService" render="Label" position="66,46" size="60,18" font="Regular;16" transparent="1" halign="right" >
108 <convert type="ServicePosition">Position</convert>
110 <widget source="session.CurrentService" render="Progress" position="6,46" size="60,18" borderWidth="1" >
111 <convert type="ServicePosition">Position</convert>
114 """<screen name="DVDSummary" position="0,0" size="96,64" id="2">
115 <widget source="session.CurrentService" render="Label" position="0,0" size="96,25" font="Regular;12" transparent="1" >
116 <convert type="ServiceName">Name</convert>
118 <widget name="DVDPlayer" position="0,26" size="96,12" font="Regular;10" transparent="1" />
119 <widget name="Chapter" position="0,40" size="66,12" font="Regular;10" transparent="1" halign="left" />
120 <widget source="session.CurrentService" render="Label" position="66,40" size="30,12" font="Regular;10" transparent="1" halign="right" >
121 <convert type="ServicePosition">Position</convert>
123 <widget source="session.CurrentService" render="Progress" position="0,52" size="96,12" borderWidth="1" >
124 <convert type="ServicePosition">Position</convert>
128 def __init__(self, session, parent):
129 Screen.__init__(self, session, parent)
131 self["DVDPlayer"] = Label("DVD Player")
132 self["Title"] = Label("")
133 self["Time"] = Label("")
134 self["Chapter"] = Label("")
136 def updateChapter(self, chapter):
137 self["Chapter"].setText(chapter)
139 def setTitle(self, title):
140 self["Title"].setText(title)
142 class DVDOverlay(Screen):
143 def __init__(self, session, args = None):
144 desktop_size = getDesktop(0).size()
145 DVDOverlay.skin = """<screen name="DVDOverlay" position="0,0" size="%d,%d" flags="wfNoBorder" zPosition="-1" backgroundColor="transparent" />""" %(desktop_size.width(), desktop_size.height())
146 Screen.__init__(self, session)
148 class ChapterZap(Screen):
150 <screen name="ChapterZap" position="235,255" size="250,60" title="Chapter" >
151 <widget name="chapter" position="35,15" size="110,25" font="Regular;23" />
152 <widget name="number" position="145,15" size="80,25" halign="right" font="Regular;23" />
161 self.close(int(self["number"].getText()))
163 def keyNumberGlobal(self, number):
164 self.Timer.start(3000, True) #reset timer
165 self.field = self.field + str(number)
166 self["number"].setText(self.field)
167 if len(self.field) >= 4:
170 def __init__(self, session, number):
171 Screen.__init__(self, session)
172 self.field = str(number)
174 self["chapter"] = Label(_("Chapter:"))
176 self["number"] = Label(self.field)
178 self["actions"] = NumberActionMap( [ "SetupActions" ],
182 "1": self.keyNumberGlobal,
183 "2": self.keyNumberGlobal,
184 "3": self.keyNumberGlobal,
185 "4": self.keyNumberGlobal,
186 "5": self.keyNumberGlobal,
187 "6": self.keyNumberGlobal,
188 "7": self.keyNumberGlobal,
189 "8": self.keyNumberGlobal,
190 "9": self.keyNumberGlobal,
191 "0": self.keyNumberGlobal
194 self.Timer = eTimer()
195 self.Timer.callback.append(self.keyOK)
196 self.Timer.start(3000, True)
198 class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarPVRState, InfoBarShowHide, HelpableScreen, InfoBarCueSheetSupport):
199 ALLOW_SUSPEND = Screen.SUSPEND_PAUSES
200 ENABLE_RESUME_SUPPORT = True
203 <screen name="DVDPlayer" flags="wfNoBorder" position="0,380" size="720,160" title="InfoBar" backgroundColor="transparent" >
205 <ePixmap position="0,0" zPosition="-2" size="720,160" pixmap="skin_default/info-bg_mp.png" alphatest="off" />
206 <ePixmap position="29,40" zPosition="0" size="665,104" pixmap="skin_default/screws_mp.png" alphatest="on" transparent="1" />
207 <!-- colorbuttons -->
208 <ePixmap position="48,70" zPosition="0" size="108,13" pixmap="skin_default/icons/mp_buttons.png" alphatest="on" />
210 <ePixmap pixmap="skin_default/icons/icon_event.png" position="207,78" zPosition="1" size="15,10" alphatest="on" />
211 <widget source="session.CurrentService" render="Label" position="230,73" size="300,22" font="Regular;20" backgroundColor="#263c59" shadowColor="#1d354c" shadowOffset="-1,-1" transparent="1" noWrap="1">
212 <convert type="ServiceName">Name</convert>
214 <!-- Chapter info -->
215 <widget name="chapterLabel" position="230,96" size="360,22" font="Regular;20" foregroundColor="#c3c3c9" backgroundColor="#263c59" transparent="1" />
216 <!-- Audio track info -->
217 <ePixmap pixmap="skin_default/icons/icon_dolby.png" position="540,60" zPosition="1" size="26,16" alphatest="on"/>
218 <widget name="audioLabel" position="570,60" size="130,22" font="Regular;18" backgroundColor="#263c59" shadowColor="#1d354c" shadowOffset="-1,-1" transparent="1" />
219 <!-- Subtitle track info -->
220 <widget source="session.CurrentService" render="Pixmap" pixmap="skin_default/icons/icon_txt.png" position="540,83" zPosition="1" size="26,16" alphatest="on" >
221 <convert type="ServiceInfo">HasTelext</convert>
222 <convert type="ConditionalShowHide" />
224 <widget name="subtitleLabel" position="570,83" size="130,22" font="Regular;18" backgroundColor="#263c59" shadowColor="#1d354c" shadowOffset="-1,-1" transparent="1" />
226 <widget name="anglePix" pixmap="skin_default/icons/icon_view.png" position="540,106" size="26,16" alphatest="on" />
227 <widget name="angleLabel" position="570,106" size="130,22" font="Regular;18" backgroundColor="#263c59" shadowColor="#1d354c" shadowOffset="-1,-1" transparent="1" />
228 <!-- Elapsed time -->
229 <widget source="session.CurrentService" render="Label" position="205,129" size="100,20" font="Regular;18" halign="center" valign="center" backgroundColor="#06224f" shadowColor="#1d354c" shadowOffset="-1,-1" transparent="1" >
230 <convert type="ServicePosition">Position,ShowHours</convert>
232 <!-- Progressbar (movie position)-->
233 <widget source="session.CurrentService" render="PositionGauge" position="300,133" size="270,10" zPosition="2" pointer="skin_default/position_pointer.png:540,0" transparent="1" >
234 <convert type="ServicePosition">Gauge</convert>
236 <!-- Remaining time -->
237 <widget source="session.CurrentService" render="Label" position="576,129" size="100,20" font="Regular;18" halign="center" valign="center" backgroundColor="#06224f" shadowColor="#1d354c" shadowOffset="-1,-1" transparent="1" >
238 <convert type="ServicePosition">Remaining,Negate,ShowHours</convert>
242 def save_infobar_seek_config(self):
243 self.saved_config_speeds_forward = config.seek.speeds_forward.value
244 self.saved_config_speeds_backward = config.seek.speeds_backward.value
245 self.saved_config_enter_forward = config.seek.enter_forward.value
246 self.saved_config_enter_backward = config.seek.enter_backward.value
247 self.saved_config_seek_on_pause = config.seek.on_pause.value
248 self.saved_config_seek_speeds_slowmotion = config.seek.speeds_slowmotion.value
250 def change_infobar_seek_config(self):
251 config.seek.speeds_forward.value = [2, 4, 8, 16, 32, 64]
252 config.seek.speeds_backward.value = [8, 16, 32, 64]
253 config.seek.speeds_slowmotion.value = [ ]
254 config.seek.enter_forward.value = "2"
255 config.seek.enter_backward.value = "2"
256 config.seek.on_pause.value = "play"
258 def restore_infobar_seek_config(self):
259 config.seek.speeds_forward.value = self.saved_config_speeds_forward
260 config.seek.speeds_backward.value = self.saved_config_speeds_backward
261 config.seek.speeds_slowmotion.value = self.saved_config_seek_speeds_slowmotion
262 config.seek.enter_forward.value = self.saved_config_enter_forward
263 config.seek.enter_backward.value = self.saved_config_enter_backward
264 config.seek.on_pause.value = self.saved_config_seek_on_pause
266 def __init__(self, session, dvd_device = None, dvd_filelist = [ ], args = None):
267 Screen.__init__(self, session)
268 InfoBarBase.__init__(self)
269 InfoBarNotifications.__init__(self)
270 InfoBarCueSheetSupport.__init__(self, actionmap = "MediaPlayerCueSheetActions")
271 InfoBarShowHide.__init__(self)
272 HelpableScreen.__init__(self)
273 self.save_infobar_seek_config()
274 self.change_infobar_seek_config()
275 InfoBarSeek.__init__(self)
276 InfoBarPVRState.__init__(self)
277 self.dvdScreen = self.session.instantiateDialog(DVDOverlay)
279 self.oldService = self.session.nav.getCurrentlyPlayingServiceReference()
280 self.session.nav.stopService()
281 self["audioLabel"] = Label("n/a")
282 self["subtitleLabel"] = Label("")
283 self["angleLabel"] = Label("")
284 self["chapterLabel"] = Label("")
285 self["anglePix"] = Pixmap()
286 self["anglePix"].hide()
287 self.last_audioTuple = None
288 self.last_subtitleTuple = None
289 self.last_angleTuple = None
290 self.totalChapters = 0
291 self.currentChapter = 0
293 self.currentTitle = 0
295 self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
297 iPlayableService.evStopped: self.__serviceStopped,
298 iPlayableService.evUser: self.__timeUpdated,
299 iPlayableService.evUser+1: self.__statePlay,
300 iPlayableService.evUser+2: self.__statePause,
301 iPlayableService.evUser+3: self.__osdFFwdInfoAvail,
302 iPlayableService.evUser+4: self.__osdFBwdInfoAvail,
303 iPlayableService.evUser+5: self.__osdStringAvail,
304 iPlayableService.evUser+6: self.__osdAudioInfoAvail,
305 iPlayableService.evUser+7: self.__osdSubtitleInfoAvail,
306 iPlayableService.evUser+8: self.__chapterUpdated,
307 iPlayableService.evUser+9: self.__titleUpdated,
308 iPlayableService.evUser+11: self.__menuOpened,
309 iPlayableService.evUser+12: self.__menuClosed,
310 iPlayableService.evUser+13: self.__osdAngleInfoAvail
313 self["DVDPlayerDirectionActions"] = ActionMap(["DirectionActions"],
315 #MENU KEY DOWN ACTIONS
316 "left": self.keyLeft,
317 "right": self.keyRight,
319 "down": self.keyDown,
321 #MENU KEY REPEATED ACTIONS
322 "leftRepeated": self.doNothing,
323 "rightRepeated": self.doNothing,
324 "upRepeated": self.doNothing,
325 "downRepeated": self.doNothing,
328 "leftUp": self.doNothing,
329 "rightUp": self.doNothing,
330 "upUp": self.doNothing,
331 "downUp": self.doNothing,
334 self["OkCancelActions"] = ActionMap(["OkCancelActions"],
337 "cancel": self.keyCancel,
340 self["DVDPlayerPlaybackActions"] = HelpableActionMap(self, "DVDPlayerActions",
343 "dvdMenu": (self.enterDVDMenu, _("show DVD main menu")),
344 "toggleInfo": (self.toggleInfo, _("toggle time, chapter, audio, subtitle info")),
345 "nextChapter": (self.nextChapter, _("forward to the next chapter")),
346 "prevChapter": (self.prevChapter, _("rewind to the previous chapter")),
347 "nextTitle": (self.nextTitle, _("jump forward to the next title")),
348 "prevTitle": (self.prevTitle, _("jump back to the previous title")),
349 "tv": (self.askLeavePlayer, _("exit DVD player or return to file browser")),
350 "dvdAudioMenu": (self.enterDVDAudioMenu, _("(show optional DVD audio menu)")),
351 "nextAudioTrack": (self.nextAudioTrack, _("switch to the next audio track")),
352 "nextSubtitleTrack": (self.nextSubtitleTrack, _("switch to the next subtitle language")),
353 "nextAngle": (self.nextAngle, _("switch to the next angle")),
354 "seekBeginning": self.seekBeginning,
357 self["NumberActions"] = NumberActionMap( [ "NumberActions"],
359 "1": self.keyNumberGlobal,
360 "2": self.keyNumberGlobal,
361 "3": self.keyNumberGlobal,
362 "4": self.keyNumberGlobal,
363 "5": self.keyNumberGlobal,
364 "6": self.keyNumberGlobal,
365 "7": self.keyNumberGlobal,
366 "8": self.keyNumberGlobal,
367 "9": self.keyNumberGlobal,
368 "0": self.keyNumberGlobal,
371 self.onClose.append(self.__onClose)
373 from Plugins.SystemPlugins.Hotplug.plugin import hotplugNotifier
374 hotplugNotifier.append(self.hotplugCB)
376 self.autoplay = dvd_device or dvd_filelist
379 self.physicalDVD = True
383 self.dvd_filelist = dvd_filelist
384 self.onFirstExecBegin.append(self.opened)
388 def keyNumberGlobal(self, number):
389 print "You pressed number " + str(number)
390 self.session.openWithCallback(self.numberEntered, ChapterZap, number)
392 def numberEntered(self, retval):
393 # print self.servicelist
395 self.zapToNumber(retval)
397 def getServiceInterface(self, iface):
398 service = self.service
400 attr = getattr(service, iface, None)
405 def __serviceStopped(self):
406 self.dvdScreen.hide()
407 subs = self.getServiceInterface("subtitle")
409 subs.disableSubtitles(self.session.current_dialog.instance)
411 def serviceStarted(self): #override InfoBarShowHide function
412 self.dvdScreen.show()
414 def doEofInternal(self, playing):
418 def __menuOpened(self):
421 self["NumberActions"].setEnabled(False)
423 def __menuClosed(self):
426 self["NumberActions"].setEnabled(True)
428 def setChapterLabel(self):
430 chapterOSD = "DVD Menu"
431 if self.currentTitle > 0:
432 chapterLCD = "%s %d" % (_("Chap."), self.currentChapter)
433 chapterOSD = "DVD %s %d/%d" % (_("Chapter"), self.currentChapter, self.totalChapters)
434 chapterOSD += " (%s %d/%d)" % (_("Title"), self.currentTitle, self.totalTitles)
435 self["chapterLabel"].setText(chapterOSD)
437 self.session.summary.updateChapter(chapterLCD)
444 def toggleInfo(self):
449 def __timeUpdated(self):
452 def __statePlay(self):
455 def __statePause(self):
458 def __osdFFwdInfoAvail(self):
459 self.setChapterLabel()
460 print "FFwdInfoAvail"
462 def __osdFBwdInfoAvail(self):
463 self.setChapterLabel()
464 print "FBwdInfoAvail"
466 def __osdStringAvail(self):
469 def __osdAudioInfoAvail(self):
470 info = self.getServiceInterface("info")
471 audioTuple = info and info.getInfoObject(iServiceInformation.sUser+6)
472 print "AudioInfoAvail ", repr(audioTuple)
474 audioString = "%d: %s (%s)" % (audioTuple[0],audioTuple[1],audioTuple[2])
475 self["audioLabel"].setText(audioString)
476 if audioTuple != self.last_audioTuple and not self.in_menu:
478 self.last_audioTuple = audioTuple
480 def __osdSubtitleInfoAvail(self):
481 info = self.getServiceInterface("info")
482 subtitleTuple = info and info.getInfoObject(iServiceInformation.sUser+7)
483 print "SubtitleInfoAvail ", repr(subtitleTuple)
486 if subtitleTuple[0] is not 0:
487 subtitleString = "%d: %s" % (subtitleTuple[0],subtitleTuple[1])
488 self["subtitleLabel"].setText(subtitleString)
489 if subtitleTuple != self.last_subtitleTuple and not self.in_menu:
491 self.last_subtitleTuple = subtitleTuple
493 def __osdAngleInfoAvail(self):
494 info = self.getServiceInterface("info")
495 angleTuple = info and info.getInfoObject(iServiceInformation.sUser+8)
496 print "AngleInfoAvail ", repr(angleTuple)
499 if angleTuple[1] > 1:
500 angleString = "%d / %d" % (angleTuple[0],angleTuple[1])
501 self["anglePix"].show()
503 self["anglePix"].hide()
504 self["angleLabel"].setText(angleString)
505 if angleTuple != self.last_angleTuple and not self.in_menu:
507 self.last_angleTuple = angleTuple
509 def __chapterUpdated(self):
510 info = self.getServiceInterface("info")
512 self.currentChapter = info.getInfo(iServiceInformation.sCurrentChapter)
513 self.totalChapters = info.getInfo(iServiceInformation.sTotalChapters)
514 self.setChapterLabel()
515 print "__chapterUpdated: %d/%d" % (self.currentChapter, self.totalChapters)
517 def __titleUpdated(self):
518 info = self.getServiceInterface("info")
520 self.currentTitle = info.getInfo(iServiceInformation.sCurrentTitle)
521 self.totalTitles = info.getInfo(iServiceInformation.sTotalTitles)
522 self.setChapterLabel()
523 print "__titleUpdated: %d/%d" % (self.currentTitle, self.totalTitles)
527 def askLeavePlayer(self):
528 choices = [(_("Exit"), "exit"), (_("Continue playing"), "play")]
529 if True or not self.physicalDVD:
530 choices.insert(1,(_("Return to file browser"), "browser"))
532 cur = self.session.nav.getCurrentlyPlayingServiceReference()
533 if cur and not cur.toString().endswith(harddiskmanager.getAutofsMountpoint(harddiskmanager.getCD())):
534 choices.insert(0,(_("Play DVD"), "playPhysical" ))
535 self.session.openWithCallback(self.exitCB, ChoiceBox, title=_("Leave DVD Player?"), list = choices)
537 def sendKey(self, key):
538 keys = self.getServiceInterface("keys")
543 def nextAudioTrack(self):
544 self.sendKey(iServiceKeys.keyUser)
546 def nextSubtitleTrack(self):
547 self.sendKey(iServiceKeys.keyUser+1)
549 def enterDVDAudioMenu(self):
550 self.sendKey(iServiceKeys.keyUser+2)
552 def nextChapter(self):
553 self.sendKey(iServiceKeys.keyUser+3)
555 def prevChapter(self):
556 self.sendKey(iServiceKeys.keyUser+4)
559 self.sendKey(iServiceKeys.keyUser+5)
562 self.sendKey(iServiceKeys.keyUser+6)
564 def enterDVDMenu(self):
565 self.sendKey(iServiceKeys.keyUser+7)
568 self.sendKey(iServiceKeys.keyUser+8)
570 def seekBeginning(self):
572 seekable = self.getSeek()
576 def zapToNumber(self, number):
578 seekable = self.getSeek()
580 print "seek to chapter %d" % number
581 seekable.seekChapter(number)
585 self.sendKey(iServiceKeys.keyRight)
588 self.sendKey(iServiceKeys.keyLeft)
591 self.sendKey(iServiceKeys.keyUp)
594 self.sendKey(iServiceKeys.keyDown)
597 if self.sendKey(iServiceKeys.keyOk) and not self.in_menu:
601 self.askLeavePlayer()
604 if self.autoplay and self.dvd_filelist:
605 # opened via autoplay
606 self.FileBrowserClosed(self.dvd_filelist[0])
607 elif self.autoplay and self.physicalDVD:
608 self.playPhysicalCB(True)
609 elif self.physicalDVD:
610 # opened from menu with dvd in drive
611 self.session.openWithCallback(self.playPhysicalCB, MessageBox, text=_("Do you want to play DVD in drive?"), timeout=5 )
613 # opened from menu without dvd in drive
614 self.session.openWithCallback(self.FileBrowserClosed, FileBrowser, self.dvd_filelist)
616 def playPhysicalCB(self, answer):
618 self.FileBrowserClosed(harddiskmanager.getAutofsMountpoint(harddiskmanager.getCD()))
620 self.session.openWithCallback(self.FileBrowserClosed, FileBrowser)
622 def FileBrowserClosed(self, val):
623 curref = self.session.nav.getCurrentlyPlayingServiceReference()
624 print "FileBrowserClosed", val
626 self.askLeavePlayer()
628 newref = eServiceReference(4369, 0, val)
629 print "play", newref.toString()
630 if curref is None or curref != newref:
631 if newref.toString().endswith("/VIDEO_TS") or newref.toString().endswith("/"):
632 names = newref.toString().rsplit("/",3)
633 if names[2].startswith("Disk ") or names[2].startswith("DVD "):
634 name = str(names[1]) + " - " + str(names[2])
637 print "setting name to: ", self.service
638 newref.setName(str(name))
639 self.session.nav.playService(newref)
640 self.service = self.session.nav.getCurrentService()
641 print "self.service", self.service
642 print "cur_dlg", self.session.current_dialog
643 subs = self.getServiceInterface("subtitle")
645 subs.enableSubtitles(self.dvdScreen.instance, None)
647 def exitCB(self, answer):
648 if answer is not None:
649 if answer[1] == "exit":
653 if answer[1] == "browser":
654 #TODO check here if a paused dvd playback is already running... then re-start it...
658 self.session.openWithCallback(self.FileBrowserClosed, FileBrowser)
659 if answer[1] == "playPhysical":
662 self.playPhysicalCB(True)
667 self.restore_infobar_seek_config()
668 self.session.nav.playService(self.oldService)
669 from Plugins.SystemPlugins.Hotplug.plugin import hotplugNotifier
670 hotplugNotifier.remove(self.hotplugCB)
672 def playLastCB(self, answer): # overwrite infobar cuesheet function
673 print "playLastCB", answer, self.resume_point
676 seekable = self.getSeek()
678 seekable.seekTo(self.resume_point)
679 pause = self.service.pause()
681 self.hideAfterResume()
683 def showAfterCuesheetOperation(self):
687 def createSummary(self):
690 #override some InfoBarSeek functions
692 self.setSeekState(self.SEEK_STATE_PLAY)
694 def calcRemainingTime(self):
697 def hotplugCB(self, dev, media_state):
698 print "[hotplugCB]", dev, media_state
699 if dev == harddiskmanager.getCD():
700 if media_state == "1":
703 self.physicalDVD = False
705 def scanHotplug(self):
706 devicepath = harddiskmanager.getAutofsMountpoint(harddiskmanager.getCD())
707 if pathExists(devicepath):
708 from Components.Scanner import scanDevice
709 res = scanDevice(devicepath)
710 list = [ (r.description, r, res[r], self.session) for r in res ]
712 (desc, scanner, files, session) = list[0]
715 if file.mimetype == "video/x-dvd":
716 print "physical dvd found:", devicepath
717 self.physicalDVD = True
719 self.physicalDVD = False
721 def main(session, **kwargs):
722 session.open(DVDPlayer)
724 def menu(menuid, **kwargs):
725 if menuid == "mainmenu":
726 return [(_("DVD Player"), main, "dvd_player", 46)]
729 from Plugins.Plugin import PluginDescriptor
731 def filescan_open(list, session, **kwargs):
732 if len(list) == 1 and list[0].mimetype == "video/x-dvd":
733 splitted = list[0].path.split('/')
734 print "splitted", splitted
735 if len(splitted) > 2:
736 if splitted[1] == 'autofs':
737 session.open(DVDPlayer, dvd_device="/dev/%s" %(splitted[2]))
740 print "splitted[0]", splitted[1]
744 if x.mimetype == "video/x-dvd-iso":
745 dvd_filelist.append(x.path)
746 if x.mimetype == "video/x-dvd":
747 dvd_filelist.append(x.path.rsplit('/',1)[0])
748 session.open(DVDPlayer, dvd_filelist=dvd_filelist)
750 def filescan(**kwargs):
751 from Components.Scanner import Scanner, ScanPath
753 # Overwrite checkFile to only detect local
754 class LocalScanner(Scanner):
755 def checkFile(self, file):
756 return fileExists(file.path)
759 LocalScanner(mimetypes = ["video/x-dvd","video/x-dvd-iso"],
762 ScanPath(path = "video_ts", with_subdirs = False),
763 ScanPath(path = "VIDEO_TS", with_subdirs = False),
764 ScanPath(path = "", with_subdirs = False),
767 description = _("Play DVD"),
768 openfnc = filescan_open,
771 def Plugins(**kwargs):
772 return [PluginDescriptor(name = "DVDPlayer", description = "Play DVDs", where = PluginDescriptor.WHERE_MENU, fnc = menu),
773 PluginDescriptor(where = PluginDescriptor.WHERE_FILESCAN, fnc = filescan)]