aboutsummaryrefslogtreecommitdiff
path: root/lib/python/Components
diff options
context:
space:
mode:
authorStefan Pluecken <stefan.pluecken@multimedia-labs.de>2006-03-23 00:06:27 +0000
committerStefan Pluecken <stefan.pluecken@multimedia-labs.de>2006-03-23 00:06:27 +0000
commit08fca93e7f2a37a452399d08c5c84b969b7e52af (patch)
treee947a919972cdd6ad072c196640a643c6c9f7fff /lib/python/Components
parent371447724a1e150c37a777e58a4725a3d2561c01 (diff)
downloadenigma2-08fca93e7f2a37a452399d08c5c84b969b7e52af.tar.gz
enigma2-08fca93e7f2a37a452399d08c5c84b969b7e52af.zip
- switchtimer added to RecordingTimer
- media player to play mp3, ogg (not yet fully working) and ts files (needs gstreamer) - language selection saves a language string instead of a changing index number
Diffstat (limited to 'lib/python/Components')
-rw-r--r--lib/python/Components/FileList.py81
-rw-r--r--lib/python/Components/Language.py17
-rw-r--r--lib/python/Components/LanguageList.py4
-rw-r--r--lib/python/Components/Makefile.am2
-rw-r--r--lib/python/Components/MediaPlayer.py124
-rw-r--r--lib/python/Components/MenuList.py20
-rw-r--r--lib/python/Components/SetupDevices.py2
-rw-r--r--lib/python/Components/TimerList.py15
8 files changed, 233 insertions, 32 deletions
diff --git a/lib/python/Components/FileList.py b/lib/python/Components/FileList.py
index 7e6ced57..d726b833 100644
--- a/lib/python/Components/FileList.py
+++ b/lib/python/Components/FileList.py
@@ -20,6 +20,7 @@ RT_VALIGN_BOTTOM = 16
EXTENSIONS = {
"mp3": "music",
"wav": "music",
+ "ogg": "music",
"jpg": "picture",
"jpeg": "picture",
"png": "picture",
@@ -29,9 +30,9 @@ EXTENSIONS = {
"mpeg": "movie",
}
-def FileEntryComponent(name, absolute, isDir = False):
+def FileEntryComponent(name, absolute = None, isDir = False):
res = [ (absolute, isDir) ]
- res.append((eListboxPythonMultiContent.TYPE_TEXT, 35, 1, 200, 20, 0, RT_HALIGN_LEFT ,name))
+ res.append((eListboxPythonMultiContent.TYPE_TEXT, 35, 1, 200, 20, 0, RT_HALIGN_LEFT, name))
if isDir:
png = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "extensions/directory.png"))
else:
@@ -39,18 +40,22 @@ def FileEntryComponent(name, absolute, isDir = False):
extension = extension[-1]
if EXTENSIONS.has_key(extension):
png = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "extensions/" + EXTENSIONS[extension] + ".png"))
+ else:
+ png = None
if png is not None:
res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 10, 2, 20, 20, png))
return res
class FileList(HTMLComponent, GUIComponent, MenuList):
- def __init__(self, directory, showDirectories = True, showFiles = True, matchingPattern = None):
+ def __init__(self, directory, showDirectories = True, showFiles = True, matchingPattern = None, useServiceRef = False, isTop = False):
GUIComponent.__init__(self)
self.l = eListboxPythonMultiContent()
-
+
+ self.useServiceRef = useServiceRef
self.showDirectories = showDirectories
self.showFiles = showFiles
+ self.isTop = isTop
# example: matching .nfi and .ts files: "^.*\.(nfi|ts)"
self.matchingPattern = matchingPattern
self.changeDir(directory)
@@ -60,35 +65,75 @@ class FileList(HTMLComponent, GUIComponent, MenuList):
def getSelection(self):
return self.l.getCurrentSelection()[0]
+ def getFileList(self):
+ return self.list
+
def changeDir(self, directory):
self.list = []
- files = os.listdir(directory)
- files.sort()
+ directories = []
+ files = []
- if directory != "/" and self.showDirectories:
- self.list.append(FileEntryComponent(name = "..", absolute = '/'.join(directory.split('/')[:-2]) + '/', isDir = True))
+ if self.useServiceRef:
+ root = eServiceReference("2:0:1:0:0:0:0:0:0:0:" + directory)
+ serviceHandler = eServiceCenter.getInstance()
+ list = serviceHandler.list(root)
- directories = []
- for x in files:
- if os.path.isdir(directory + x):
- directories.append(x)
- files.remove(x)
+ while 1:
+ s = list.getNext()
+ if not s.valid():
+ del list
+ break
+ if s.flags & s.mustDescent:
+ directories.append(s.getPath())
+ else:
+ files.append(s)
+ print s.getName(), s.flags
+ else:
+ files = os.listdir(directory)
+ files.sort()
+ tmpfiles = files[:]
+ for x in tmpfiles:
+ if os.path.isdir(directory + x):
+ directories.append(x)
+ files.remove(x)
+
+ if directory != "/" and self.showDirectories and not self.isTop:
+ self.list.append(FileEntryComponent(name = "..", absolute = '/'.join(directory.split('/')[:-2]) + '/', isDir = True))
if self.showDirectories:
for x in directories:
- self.list.append(FileEntryComponent(name = x, absolute = directory + x + "/" , isDir = True))
+ name = x.split('/')[-2]
+ self.list.append(FileEntryComponent(name = name, absolute = x, isDir = True))
-
if self.showFiles:
for x in files:
+ if self.useServiceRef:
+ path = x.getPath()
+ name = path.split('/')[-1]
+ else:
+ path = directory + x
+ name = x
+
if self.matchingPattern is not None:
- if re.compile(self.matchingPattern).search(x):
- self.list.append(FileEntryComponent(name = x, absolute = directory + x , isDir = False))
+ if re.compile(self.matchingPattern).search(path):
+ self.list.append(FileEntryComponent(name = name, absolute = x , isDir = False))
else:
- self.list.append(FileEntryComponent(name = x, absolute = directory + x , isDir = False))
+ self.list.append(FileEntryComponent(name = name, absolute = x , isDir = False))
self.l.setList(self.list)
+
+ def canDescent(self):
+ return self.getSelection()[1]
+
+ def descent(self):
+ self.changeDir(self.getSelection()[0])
+
+ def getFilename(self):
+ return self.getSelection()[0].getPath()
+
+ def getServiceRef(self):
+ return self.getSelection()[0]
def GUIcreate(self, parent):
self.instance = eListbox(parent)
diff --git a/lib/python/Components/Language.py b/lib/python/Components/Language.py
index 51ee9142..fd37e167 100644
--- a/lib/python/Components/Language.py
+++ b/lib/python/Components/Language.py
@@ -7,7 +7,7 @@ class Language:
def __init__(self):
gettext.install('enigma2', resolveFilename(SCOPE_LANGUAGE, ""), unicode=0, codeset="utf-8")
self.activeLanguage = 0
- self.lang = []
+ self.lang = {}
# FIXME make list dynamically
# name, iso-639 language, iso-3166 country. Please don't mix language&country!
self.addLanguage(_("English"), "en", "EN")
@@ -20,10 +20,10 @@ class Language:
self.callbacks = []
def addLanguage(self, name, lang, country):
- try:
- self.lang.append((_(name), gettext.translation('enigma2', resolveFilename(SCOPE_LANGUAGE, ""), languages=[lang]), lang, country))
- except:
- print "Language " + str(name) + " not found"
+ #try:
+ self.lang[str(lang + "_" + country)] = ((_(name), gettext.translation('enigma2', resolveFilename(SCOPE_LANGUAGE, ""), languages=[lang]), lang, country))
+ #except:
+ # print "Language " + str(name) + " not found"
def activateLanguage(self, index):
try:
@@ -37,10 +37,13 @@ class Language:
def getLanguageList(self):
list = []
- for x in self.lang:
- list.append(x[0])
+ for x in self.lang.keys():
+ list.append((x, self.lang[x]))
return list
+ def getActiveLanguage(self):
+ return self.activeLanguage
+
def getLanguage(self):
return str(self.lang[self.activeLanguage][2]) + "_" + str(self.lang[self.activeLanguage][3])
diff --git a/lib/python/Components/LanguageList.py b/lib/python/Components/LanguageList.py
index 08bb6307..adf87186 100644
--- a/lib/python/Components/LanguageList.py
+++ b/lib/python/Components/LanguageList.py
@@ -16,8 +16,8 @@ RT_VALIGN_TOP = 0
RT_VALIGN_CENTER = 8
RT_VALIGN_BOTTOM = 16
-def LanguageEntryComponent(file, name):
- res = [ 0 ]
+def LanguageEntryComponent(file, name, index):
+ res = [ index ]
res.append((eListboxPythonMultiContent.TYPE_TEXT, 80, 10, 200, 50, 0, RT_HALIGN_LEFT ,name))
png = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "countries/" + file + ".png"))
if png == None:
diff --git a/lib/python/Components/Makefile.am b/lib/python/Components/Makefile.am
index a41c210f..94a8c06c 100644
--- a/lib/python/Components/Makefile.am
+++ b/lib/python/Components/Makefile.am
@@ -13,6 +13,6 @@ install_PYTHON = \
BlinkingPixmap.py Pixmap.py ConditionalWidget.py Slider.py LanguageList.py \
PluginList.py PluginComponent.py RecordingConfig.py About.py UsageConfig.py \
FIFOList.py ServiceEventTracker.py Input.py TimerSanityCheck.py FileList.py \
- MultiContent.py
+ MultiContent.py MediaPlayer.py
diff --git a/lib/python/Components/MediaPlayer.py b/lib/python/Components/MediaPlayer.py
new file mode 100644
index 00000000..b6b2e432
--- /dev/null
+++ b/lib/python/Components/MediaPlayer.py
@@ -0,0 +1,124 @@
+from HTMLComponent import *
+from GUIComponent import *
+
+from MenuList import MenuList
+
+from Tools.Directories import *
+import os
+
+from enigma import *
+
+RT_HALIGN_LEFT = 0
+RT_HALIGN_RIGHT = 1
+RT_HALIGN_CENTER = 2
+RT_HALIGN_BLOCK = 4
+
+RT_VALIGN_TOP = 0
+RT_VALIGN_CENTER = 8
+RT_VALIGN_BOTTOM = 16
+
+STATE_PLAY = 0
+STATE_PAUSE = 1
+STATE_STOP = 2
+STATE_REWIND = 3
+STATE_FORWARD = 4
+STATE_NONE = 5
+
+PlayIcon = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "play-small-fs8.png"))
+PauseIcon = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "pause-small-fs8.png"))
+StopIcon = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "stop-small-fs8.png"))
+RewindIcon = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "rewind-small-fs8.png"))
+ForwardIcon = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, "forward-small-fs8.png"))
+
+def PlaylistEntryComponent(serviceref, state):
+ res = [ serviceref ]
+ res.append((eListboxPythonMultiContent.TYPE_TEXT, 35, 0, 250, 32, 0, RT_VALIGN_CENTER, os.path.split(serviceref.getPath().split('/')[-1])[1]))
+ png = None
+ if state == STATE_PLAY:
+ png = PlayIcon
+ elif state == STATE_PAUSE:
+ png = PauseIcon
+ elif state == STATE_STOP:
+ png = StopIcon
+ elif state == STATE_REWIND:
+ png = RewindIcon
+ elif state == STATE_FORWARD:
+ png = ForwardIcon
+
+ if png is not None:
+ res.append((eListboxPythonMultiContent.TYPE_PIXMAP, 0, 0, 33, 32, png))
+
+ return res
+
+class PlayList(HTMLComponent, GUIComponent, MenuList):
+ def __init__(self):
+ GUIComponent.__init__(self)
+ self.l = eListboxPythonMultiContent()
+ self.list = []
+ self.l.setList(self.list)
+ self.l.setFont(0, gFont("Regular", 18))
+ self.currPlaying = 0
+ self.oldCurrPlaying = -1
+
+ def clear(self):
+ self.list = []
+ self.l.setList(self.list)
+
+ def GUIcreate(self, parent):
+ self.instance = eListbox(parent)
+ self.instance.setContent(self.l)
+ self.instance.setItemHeight(32)
+
+ def getSelection(self):
+ return self.l.getCurrentSelection()[0]
+
+ def getSelectionIndex(self):
+ return self.l.getCurrentSelectionIndex()
+
+ def addFile(self, serviceref):
+ self.list.append(PlaylistEntryComponent(serviceref, STATE_NONE))
+
+ def deleteFile(self, index):
+ if self.currPlaying > index:
+ self.currPlaying -= 1
+ self.list = self.list[:index] + self.list[index + 1:]
+
+ def setCurrentPlaying(self, index):
+ self.oldCurrPlaying = self.currPlaying
+ self.currPlaying = index
+
+ def updateState(self, state):
+ if len(self.list) > self.oldCurrPlaying and self.oldCurrPlaying != -1:
+ self.list[self.oldCurrPlaying] = PlaylistEntryComponent(self.list[self.oldCurrPlaying][0], STATE_NONE)
+ self.list[self.currPlaying] = PlaylistEntryComponent(self.list[self.currPlaying][0], state)
+ self.updateList()
+
+ def playFile(self):
+ self.updateState(STATE_PLAY)
+
+ def pauseFile(self):
+ self.updateState(STATE_PAUSE)
+
+ def stopFile(self):
+ self.updateState(STATE_STOP)
+
+ def rewindFile(self):
+ self.updateState(STATE_REWIND)
+
+ def forwardFile(self):
+ self.updateState(STATE_FORWARD)
+
+ def updateList(self):
+ self.l.setList(self.list)
+
+ def getCurrentIndex(self):
+ return self.currPlaying
+
+ def getServiceRefList(self):
+ list = []
+ for x in self.list:
+ list.append(x[0])
+ return list
+
+ def __len__(self):
+ return len(self.list) \ No newline at end of file
diff --git a/lib/python/Components/MenuList.py b/lib/python/Components/MenuList.py
index b12cb236..0e337198 100644
--- a/lib/python/Components/MenuList.py
+++ b/lib/python/Components/MenuList.py
@@ -33,3 +33,23 @@ class MenuList(HTMLComponent, GUIComponent):
def moveToIndex(self, idx):
self.instance.moveSelectionTo(idx)
+
+ def pageUp(self):
+ if self.instance is not None:
+ self.instance.moveSelection(self.instance.pageUp)
+
+ def pageDown(self):
+ if self.instance is not None:
+ self.instance.moveSelection(self.instance.pageDown)
+
+ def up(self):
+ if self.instance is not None:
+ self.instance.moveSelection(self.instance.moveUp)
+
+ def down(self):
+ if self.instance is not None:
+ self.instance.moveSelection(self.instance.moveDown)
+
+ def selectionEnabled(self, enabled):
+ if self.instance is not None:
+ self.instance.setSelectionEnable(enabled) \ No newline at end of file
diff --git a/lib/python/Components/SetupDevices.py b/lib/python/Components/SetupDevices.py
index 3398af71..9036fa63 100644
--- a/lib/python/Components/SetupDevices.py
+++ b/lib/python/Components/SetupDevices.py
@@ -31,7 +31,7 @@ def InitSetupDevices():
def languageNotifier(configElement):
language.activateLanguage(configElement.value)
- config.osd.language = configElement("config.osd.language", configSelection, 0, language.getLanguageList() );
+ config.osd.language = configElement("config.osd.language", configText, "en_EN", 0);
config.osd.language.addNotifier(languageNotifier)
config.parental = ConfigSubsection();
diff --git a/lib/python/Components/TimerList.py b/lib/python/Components/TimerList.py
index 5e371a04..645c32ba 100644
--- a/lib/python/Components/TimerList.py
+++ b/lib/python/Components/TimerList.py
@@ -42,9 +42,15 @@ def TimerEntryComponent(timer, processed):
repeatedtext += days[x]
count += 1
flags = flags >> 1
- res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 50, 400, 20, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, repeatedtext + (" %s ... %s" % (FuzzyTime(timer.begin)[1], FuzzyTime(timer.end)[1]))))
+ if timer.justplay:
+ res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 50, 400, 20, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, repeatedtext + ((" %s "+ _("(ZAP)")) % (FuzzyTime(timer.begin)[1], FuzzyTime(timer.end)[1]))))
+ else:
+ res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 50, 400, 20, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, repeatedtext + (" %s ... %s" % (FuzzyTime(timer.begin)[1], FuzzyTime(timer.end)[1]))))
else:
- res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 50, 400, 20, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, repeatedtext + ("%s, %s ... %s" % (FuzzyTime(timer.begin) + FuzzyTime(timer.end)[1:]))))
+ if timer.justplay:
+ res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 50, 400, 20, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, repeatedtext + (("%s, %s " + _("(ZAP)")) % (FuzzyTime(timer.begin)))))
+ else:
+ res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 50, 400, 20, 1, RT_HALIGN_LEFT|RT_VALIGN_CENTER, repeatedtext + ("%s, %s ... %s" % (FuzzyTime(timer.begin) + FuzzyTime(timer.end)[1:]))))
if not processed:
if timer.state == TimerEntry.StateWaiting:
@@ -52,7 +58,10 @@ def TimerEntryComponent(timer, processed):
elif timer.state == TimerEntry.StatePrepared:
state = _("about to start")
elif timer.state == TimerEntry.StateRunning:
- state = _("recording...")
+ if timer.justplay:
+ state = _("zapped")
+ else:
+ state = _("recording...")
else:
state = _("<unknown>")
else: