X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/63ad55839aa3ab4902c4e62063259a49a17e7f49..7f399d23032b1e6d39123db87bdfa98a778c9ffd:/lib/python/Plugins/Extensions/DVDPlayer/plugin.py diff --git a/lib/python/Plugins/Extensions/DVDPlayer/plugin.py b/lib/python/Plugins/Extensions/DVDPlayer/plugin.py index 45c5ddee..6a69de42 100644 --- a/lib/python/Plugins/Extensions/DVDPlayer/plugin.py +++ b/lib/python/Plugins/Extensions/DVDPlayer/plugin.py @@ -56,6 +56,10 @@ class FileBrowser(Screen): self.close(filename[0:-9]) if self["filelist"].canDescent(): # isDir self["filelist"].descent() + pathname = self["filelist"].getCurrentDirectory() or "" + if fileExists(pathname+"VIDEO_TS.IFO"): + print "dvd structure found, trying to open..." + self.close(pathname) else: self.close(filename) @@ -219,7 +223,7 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP config.seek.stepwise_repeat.value = self.saved_config_seek_stepwise_repeat config.seek.on_pause.value = self.saved_config_seek_on_pause - def __init__(self, session, args = None): + def __init__(self, session, dvd_device = None, args = None): Screen.__init__(self, session) InfoBarBase.__init__(self) InfoBarNotifications.__init__(self) @@ -228,7 +232,7 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP HelpableScreen.__init__(self) self.save_infobar_seek_config() self.change_infobar_seek_config() - InfoBarSeek.__init__(self) + InfoBarSeek.__init__(self, useSeekBackHack=False) InfoBarPVRState.__init__(self) self.dvdScreen = self.session.instantiateDialog(DVDOverlay) @@ -244,6 +248,7 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP self.__event_tracker = ServiceEventTracker(screen=self, eventmap= { + iPlayableService.evStopped: self.__serviceStopped, iPlayableService.evUser: self.__timeUpdated, iPlayableService.evUser+1: self.__statePlay, iPlayableService.evUser+2: self.__statePause, @@ -317,10 +322,26 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP }) self.onClose.append(self.__onClose) + + if dvd_device: + self.dvd_device = dvd_device + self.physicalDVD = True + else: + if fileExists("/dev/cdroms/cdrom0"): + print "physical dvd found (/dev/cdroms/cdrom0)" + self.dvd_device = "/dev/cdroms/cdrom0" + self.physicalDVD = True + else: + self.dvd_device = None + self.physicalDVD = False + self.onFirstExecBegin.append(self.showFileBrowser) self.service = None self.in_menu = False - + self.old_aspect = open("/proc/stb/video/aspect", "r").read() + self.old_policy = open("/proc/stb/video/policy", "r").read() + self.old_wss = open("/proc/stb/denc/0/wss", "r").read() + def keyNumberGlobal(self, number): print "You pressed number " + str(number) self.session.openWithCallback(self.numberEntered, ChapterZap, number) @@ -330,8 +351,13 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP if retval > 0: self.zapToNumber(retval) + def __serviceStopped(self): + self.dvdScreen.hide() + self.service.subtitle().disableSubtitles(self.session.current_dialog.instance) + def serviceStarted(self): #override InfoBarShowHide function - pass + self.dvdScreen.show() + self.service.subtitle().enableSubtitles(self.dvdScreen.instance, None) def doEofInternal(self, playing): if self.in_menu: @@ -389,28 +415,28 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP print "StringAvail" def __osdAudioInfoAvail(self): - audioString = self.service.info().getInfoString(iPlayableService.evUser+6) + audioString = self.service.info().getInfoString(iServiceInformation.sUser+6) print "AudioInfoAvail "+audioString self["audioLabel"].setText(audioString) if not self.in_menu: self.doShow() def __osdSubtitleInfoAvail(self): - subtitleString = self.service.info().getInfoString(iPlayableService.evUser+7) + subtitleString = self.service.info().getInfoString(iServiceInformation.sUser+7) print "SubtitleInfoAvail "+subtitleString self["subtitleLabel"].setText(subtitleString) if not self.in_menu: self.doShow() def __chapterUpdated(self): - self.currentChapter = self.service.info().getInfo(iPlayableService.evUser+8) - self.totalChapters = self.service.info().getInfo(iPlayableService.evUser+80) + self.currentChapter = self.service.info().getInfo(iServiceInformation.sUser+8) + self.totalChapters = self.service.info().getInfo(iServiceInformation.sUser+80) self.setChapterLabel() print "__chapterUpdated: %d/%d" % (self.currentChapter, self.totalChapters) def __titleUpdated(self): - self.currentTitle = self.service.info().getInfo(iPlayableService.evUser+9) - self.totalTitles = self.service.info().getInfo(iPlayableService.evUser+90) + self.currentTitle = self.service.info().getInfo(iServiceInformation.sUser+9) + self.totalTitles = self.service.info().getInfo(iServiceInformation.sUser+90) self.setChapterLabel() print "__titleUpdated: %d/%d" % (self.currentTitle, self.totalTitles) if not self.in_menu: @@ -421,7 +447,10 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP #self.__osdSubtitleInfoAvail() def askLeavePlayer(self): - self.session.openWithCallback(self.exitCB, ChoiceBox, title=_("Leave DVD Player?"), list=[(_("Exit"), "exit"), (_("Return to file browser"), "browser"), (_("Continue playing"), "play")]) + if self.physicalDVD: + self.session.openWithCallback(self.exitCB, ChoiceBox, title=_("Leave DVD Player?"), list=[(_("Continue playing"), "play"), (_("Exit"), "exit")]) + else: + self.session.openWithCallback(self.exitCB, ChoiceBox, title=_("Leave DVD Player?"), list=[(_("Continue playing"), "play"), (_("Return to file browser"), "browser"), (_("Exit"), "exit")]) def nextAudioTrack(self): if self.service: @@ -454,13 +483,13 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP def enterDVDMenu(self): if self.service: self.service.keys().keyPressed(iServiceKeys.keyUser+7) - + def seekBeginning(self): if self.service: seekable = self.getSeek() if seekable is not None: seekable.seekTo(0) - + def zapToNumber(self, number): if self.service: seekable = self.getSeek() @@ -495,7 +524,19 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP self.askLeavePlayer() def showFileBrowser(self): - self.session.openWithCallback(self.FileBrowserClosed, FileBrowser) + if self.physicalDVD: + if self.dvd_device == "/dev/cdroms/cdrom0": + self.session.openWithCallback(self.DVDdriveCB, MessageBox, text=_("Do you want to play DVD in drive?"), timeout=5 ) + else: + self.DVDdriveCB(True) + else: + self.session.openWithCallback(self.FileBrowserClosed, FileBrowser) + + def DVDdriveCB(self, answer): + if answer == True: + self.FileBrowserClosed(self.dvd_device) + else: + self.session.openWithCallback(self.FileBrowserClosed, FileBrowser) def FileBrowserClosed(self, val): curref = self.session.nav.getCurrentlyPlayingServiceReference() @@ -510,15 +551,11 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP self.service = self.session.nav.getCurrentService() print "self.service", self.service print "cur_dlg", self.session.current_dialog - self.dvdScreen.show() - self.service.subtitle().enableSubtitles(self.dvdScreen.instance, None) def exitCB(self, answer): if answer is not None: if answer[1] == "exit": if self.service: - self.dvdScreen.hide() - self.service.subtitle().disableSubtitles(self.session.current_dialog.instance) self.service = None self.close() if answer[1] == "browser": @@ -529,6 +566,11 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP pass def __onClose(self): + for i in (("/proc/stb/video/aspect", self.old_aspect), ("/proc/stb/video/policy", self.old_policy), ("/proc/stb/denc/0/wss", self.old_wss)): + try: + open(i[0], "w").write(i[1]) + except IOError: + print "restore", i[0], "failed" self.restore_infobar_seek_config() self.session.nav.playService(self.oldService) @@ -576,5 +618,39 @@ def menu(menuid, **kwargs): return [] from Plugins.Plugin import PluginDescriptor + +#TODO add *.iso to filescanner and ask when more than one iso file is found + +def filescan_open(list, session, **kwargs): + for x in list: + splitted = x.path.split('/') + print "splitted", splitted + if len(splitted) > 2: + if splitted[1] == 'autofs': + session.open(DVDPlayer, "/dev/%s" %(splitted[2])) + return + else: + print "splitted[0]", splitted[1] + +def filescan(**kwargs): + from Components.Scanner import Scanner, ScanPath + + # Overwrite checkFile to only detect local + class LocalScanner(Scanner): + def checkFile(self, file): + return fileExists(file.path) + + return \ + LocalScanner(mimetypes = None, + paths_to_scan = + [ + ScanPath(path = "video_ts", with_subdirs = False), + ], + name = "DVD", + description = "Play DVD", + openfnc = filescan_open, + ) + def Plugins(**kwargs): - return [PluginDescriptor(name = "DVDPlayer", description = "Play DVDs", where = PluginDescriptor.WHERE_MENU, fnc = menu)] + return [PluginDescriptor(name = "DVDPlayer", description = "Play DVDs", where = PluginDescriptor.WHERE_MENU, fnc = menu), + PluginDescriptor(where = PluginDescriptor.WHERE_FILESCAN, fnc = filescan)]