aboutsummaryrefslogtreecommitdiff
path: root/lib/python/Plugins
diff options
context:
space:
mode:
authorFraxinas <andreas.frisch@multimedia-labs.de>2009-03-02 17:28:35 +0100
committerFraxinas <andreas.frisch@multimedia-labs.de>2009-03-02 17:28:35 +0100
commit8d2545bc513280abe52d9c0fc2b704de3729a11e (patch)
treeb19e8a158ddb4dd0719779be98524a72e234759f /lib/python/Plugins
parent4b8fe9d6650b7527b3c588f72540cea3c04423b9 (diff)
downloadenigma2-8d2545bc513280abe52d9c0fc2b704de3729a11e.tar.gz
enigma2-8d2545bc513280abe52d9c0fc2b704de3729a11e.zip
listen to hotplug event when dvd is inserted or ejected and modify EXIT menu accordingly
Diffstat (limited to 'lib/python/Plugins')
-rw-r--r--lib/python/Plugins/Extensions/DVDPlayer/plugin.py78
1 files changed, 48 insertions, 30 deletions
diff --git a/lib/python/Plugins/Extensions/DVDPlayer/plugin.py b/lib/python/Plugins/Extensions/DVDPlayer/plugin.py
index 6a8ffc6f..ce2e5938 100644
--- a/lib/python/Plugins/Extensions/DVDPlayer/plugin.py
+++ b/lib/python/Plugins/Extensions/DVDPlayer/plugin.py
@@ -14,6 +14,7 @@ from Components.ServiceEventTracker import ServiceEventTracker, InfoBarBase
from Components.config import config
from Tools.Directories import pathExists, fileExists
from Components.Harddisk import harddiskmanager
+from Plugins.SystemPlugins.Hotplug.plugin import hotplugNotifier
import servicedvd # load c++ part of dvd player plugin
@@ -345,28 +346,15 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP
})
self.onClose.append(self.__onClose)
- self.physicalDVD = False
- self.dvd_device = None
+ hotplugNotifier.append(self.hotplugCB)
+
if dvd_device:
- self.dvd_device = dvd_device
- self.physicalDVD = True
+ self.physicalDVD = True
else:
- devicepath = harddiskmanager.getAutofsMountpoint(harddiskmanager.getCD())
- if pathExists(devicepath):
- from Components.Scanner import scanDevice
- res = scanDevice(devicepath)
- list = [ (r.description, r, res[r], self.session) for r in res ]
- if list:
- (desc, scanner, files, session) = list[0]
- for file in files:
- print file
- if file.mimetype == "video/x-dvd":
- self.dvd_device = devicepath
- print "physical dvd found:", self.dvd_device
- self.physicalDVD = True
+ self.scanHotplug()
self.dvd_filelist = dvd_filelist
- self.onFirstExecBegin.append(self.showFileBrowser)
+ self.onFirstExecBegin.append(self.opened)
self.service = None
self.in_menu = False
@@ -513,6 +501,8 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP
choices = [(_("Exit"), "exit"), (_("Continue playing"), "play")]
if True or not self.physicalDVD:
choices.insert(1,(_("Return to file browser"), "browser"))
+ if self.physicalDVD and not self.session.nav.getCurrentlyPlayingServiceReference().toString().endswith(harddiskmanager.getAutofsMountpoint(harddiskmanager.getCD())):
+ choices.insert(0,(_("Play DVD"), "playPhysical" ))
self.session.openWithCallback(self.exitCB, ChoiceBox, title=_("Leave DVD Player?"), list = choices)
def sendKey(self, key):
@@ -581,23 +571,22 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP
def keyCancel(self):
self.askLeavePlayer()
- def showFileBrowser(self):
- if self.physicalDVD and len(self.dvd_filelist) == 0:
- if self.dvd_device == harddiskmanager.getAutofsMountpoint(harddiskmanager.getCD()):
- self.session.openWithCallback(self.DVDdriveCB, MessageBox, text=_("Do you want to play DVD in drive?"), timeout=5 )
- else:
- self.DVDdriveCB(True)
- elif len(self.dvd_filelist) == 1:
+ def opened(self):
+ if len(self.dvd_filelist) == 1:
+ # opened via autoplay
self.FileBrowserClosed(self.dvd_filelist[0])
+ elif self.physicalDVD:
+ # opened from menu with dvd in drive
+ self.session.openWithCallback(self.playPhysicalCB, MessageBox, text=_("Do you want to play DVD in drive?"), timeout=5 )
else:
+ # opened from menu without dvd in drive
self.session.openWithCallback(self.FileBrowserClosed, FileBrowser, self.dvd_filelist)
-
- def DVDdriveCB(self, answer):
+
+ def playPhysicalCB(self, answer):
if answer == True:
- self.FileBrowserClosed(self.dvd_device)
+ self.FileBrowserClosed(harddiskmanager.getAutofsMountpoint(harddiskmanager.getCD()))
else:
self.session.openWithCallback(self.FileBrowserClosed, FileBrowser)
- self.physicalDVD = False
def FileBrowserClosed(self, val):
curref = self.session.nav.getCurrentlyPlayingServiceReference()
@@ -627,13 +616,18 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP
#else
if self.service:
self.service = None
- self.showFileBrowser()
+ self.session.openWithCallback(self.FileBrowserClosed, FileBrowser)
+ if answer[1] == "playPhysical":
+ if self.service:
+ self.service = None
+ self.playPhysicalCB(True)
else:
pass
def __onClose(self):
self.restore_infobar_seek_config()
self.session.nav.playService(self.oldService)
+ hotplugNotifier.remove(self.hotplugCB)
def playLastCB(self, answer): # overwrite infobar cuesheet function
print "playLastCB", answer, self.resume_point
@@ -660,6 +654,30 @@ class DVDPlayer(Screen, InfoBarBase, InfoBarNotifications, InfoBarSeek, InfoBarP
def calcRemainingTime(self):
return 0
+ def hotplugCB(self, dev, media_state):
+ print "[hotplugCB]", dev, media_state
+ if dev == harddiskmanager.getCD():
+ if media_state == "1":
+ self.scanHotplug()
+ else:
+ self.physicalDVD = False
+
+ def scanHotplug(self):
+ devicepath = harddiskmanager.getAutofsMountpoint(harddiskmanager.getCD())
+ if pathExists(devicepath):
+ from Components.Scanner import scanDevice
+ res = scanDevice(devicepath)
+ list = [ (r.description, r, res[r], self.session) for r in res ]
+ if list:
+ (desc, scanner, files, session) = list[0]
+ for file in files:
+ print file
+ if file.mimetype == "video/x-dvd":
+ print "physical dvd found:", devicepath
+ self.physicalDVD = True
+ return
+ self.physicalDVD = False
+
def main(session, **kwargs):
session.open(DVDPlayer)