add radio player
authorAndreas Monzner <andreas.monzner@multimedia-labs.de>
Thu, 5 Jan 2006 20:28:04 +0000 (20:28 +0000)
committerAndreas Monzner <andreas.monzner@multimedia-labs.de>
Thu, 5 Jan 2006 20:28:04 +0000 (20:28 +0000)
TODO: change layout in skin.xml (ChannelSelectionRadio ... add nice pixmap ? ! ?)
TODO: add infobar infos (now/next starttime, title, duration to player)
TODO: add nice background pic ? ! ?

data/keymap.xml
data/skin.xml
lib/python/Screens/ChannelSelection.py
lib/python/Screens/InfoBar.py

index 46e80c09d5bd218d8a1333b9bf5d70b68ca0c5ac..24c36a8f52759054217a323c196e6a8e341b1b9e 100644 (file)
@@ -97,6 +97,7 @@
 
        <map context="InfobarActions">
                <key id="KEY_VIDEO" mapto="showMovies" flags="m" />
+               <key id="KEY_RADIO" mapto="showRadio" flags="m" />
        </map>
 
        <map context="InfobarAudioSelectionActions">
                <key id="KEY_0" mapto="0" flags="m" />
        </map>
 
+       <map context="ContextMenuActions">
+               <key id="KEY_MENU" mapto="contextMenu" flags="m" />
+       </map>
+
+       <map context="TvRadioActions">
+               <key id="KEY_TV" mapto="keyTV" flags="m" />
+               <key id="KEY_RADIO" mapto="keyRadio" flags="m" />
+       </map>
+
        <map context="EPGSelectActions">
                <key id="KEY_GREEN" mapto="timerAdd" flags="m" />
                <key id="KEY_YELLOW" mapto="yellow" flags="m" />
        <map context="StandbyActions">
                <key id="KEY_POWER" mapto="power" flags="m" />
        </map>
-       <map context="ContextMenuActions">
-               <key id="KEY_MENU" mapto="contextMenu" flags="m" />
-       </map>
 </keymap>
index 95ff48eb5f22fee7b1ba5370df34ad821f8cd094..9ce0bb7c3e3eac985e5d85ac7bdf384b617ce0ba 100644 (file)
                        <widget name="key_yellow" position="280,0" size="140,40" backgroundColor="yellow" font="Regular;21" />
                        <widget name="key_blue" position="420,0" size="140,40" backgroundColor="blue" font="Regular;21" />
                </screen>
+               <screen name="ChannelSelectionRadio" position="90,98" size="560,417" title="Channel Selection">
+                       <widget name="list" position="00,45" size="560,304" scrollbarMode="showOnDemand" />
+                       <widget name="key_red" position="0,0" size="140,40" backgroundColor="red" font="Regular;21" />
+                       <widget name="key_green" position="140,0" size="140,40" backgroundColor="green" font="Regular;21" />
+                       <widget name="key_yellow" position="280,0" size="140,40" backgroundColor="yellow" font="Regular;21" />
+                       <widget name="key_blue" position="420,0" size="140,40" backgroundColor="blue" font="Regular;21" />
+               </screen>
                <screen name="SimpleChannelSelection" position="90,98" size="560,417" title="Channel Selection">
                        <widget name="list" position="00,45" size="560,364" scrollbarMode="showOnDemand" />
                        <widget name="key_red" position="0,0" size="140,40" backgroundColor="red" font="Regular;21" />
index adc689454b65d35d8dcca265ed162be9cd3f62c5..cad9961624389e050ff34431969ecb464417425b 100644 (file)
@@ -235,19 +235,16 @@ class ChannelSelectionEdit:
 
 USE_MULTIBOUQUETS = False
 
+MODE_TV = 0
+MODE_RADIO = 1
+
 class ChannelSelectionBase(Screen):
        def __init__(self, session):
                Screen.__init__(self, session)
 
                # this makes it much simple to implement a selectable radio or tv mode :)
                self.service_types_tv = '1:7:1:0:0:0:0:0:0:0:(type == 1) || (type == 17)'
-#              self.service_types_radio = '1:7:1:0:0:0:0:0:0:0:(type == 2)'
-
-               self.service_types = self.service_types_tv
-               if USE_MULTIBOUQUETS:
-                       self.bouquet_root = eServiceReference('1:7:1:0:0:0:0:0:0:0:(type == 1) FROM BOUQUET "bouquets.tv" ORDER BY bouquet')
-               else:
-                       self.bouquet_root = eServiceReference('%s FROM BOUQUET "userbouquet.favourites.tv" ORDER BY bouquet'%(self.service_types))
+               self.service_types_radio = '1:7:1:0:0:0:0:0:0:0:(type == 2)'
 
                self["key_red"] = Button(_("All"))
                self["key_green"] = Button(_("Satellites"))
@@ -257,8 +254,6 @@ class ChannelSelectionBase(Screen):
                self["list"] = ServiceList()
                self.servicelist = self["list"]
 
-               #self["okbutton"] = Button("ok", [self.channelSelected])
-
                self.numericalTextInput = NumericalTextInput()
 
        def appendDVBTypes(self, ref):
@@ -293,6 +288,34 @@ class ChannelSelectionBase(Screen):
                                                offsetCount += 1
                return offsetCount
 
+       def setTvMode(self):
+               self.service_types = self.service_types_tv
+               if USE_MULTIBOUQUETS:
+                       self.bouquet_root = eServiceReference('1:7:1:0:0:0:0:0:0:0:(type == 1) FROM BOUQUET "bouquets.tv" ORDER BY bouquet')
+               else:
+                       self.bouquet_root = eServiceReference('%s FROM BOUQUET "userbouquet.favourites.tv" ORDER BY bouquet'%(self.service_types))
+               title = self.instance.getTitle()
+               pos = title.find(" (")
+               if pos != -1:
+                       title = title[:pos]
+               title += " (TV)"
+               self.instance.setTitle(title)
+               self.mode = MODE_TV
+
+       def setRadioMode(self):
+               self.service_types = self.service_types_radio
+               if USE_MULTIBOUQUETS:
+                       self.bouquet_root = eServiceReference('1:7:1:0:0:0:0:0:0:0:(type == 1) FROM BOUQUET "bouquets.radio" ORDER BY bouquet')
+               else:
+                       self.bouquet_root = eServiceReference('%s FROM BOUQUET "userbouquet.favourites.radio" ORDER BY bouquet'%(self.service_types))
+               title = self.instance.getTitle()
+               pos = title.find(" (")
+               if pos != -1:
+                       title = title[:pos]
+               title += " (Radio)"
+               self.instance.setTitle(title)
+               self.mode = MODE_RADIO
+
        def setRootBase(self, root, justSet=False):
                path = root.getPath()
                inBouquetRootList = path.find('FROM BOUQUET "bouquets.') != -1 #FIXME HACK
@@ -441,22 +464,23 @@ class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit):
                self["actions"].csel = self
                self.onShown.append(self.onShow)
 
-#              self.onLayoutFinish.append(self.onCreate)
                self.lastChannelRootTimer = eTimer()
                self.lastChannelRootTimer.timeout.get().append(self.onCreate)
                self.lastChannelRootTimer.start(100,True)
 
        def onCreate(self):
+               self.setTvMode()
                lastroot=eServiceReference(config.tv.lastroot.value)
                if lastroot.valid():
                        self.setRoot(lastroot)
                else:
                        self.showFavourites()
                        self.saveRoot(self.getRoot())
+
                lastservice=eServiceReference(config.tv.lastservice.value)
                if lastservice.valid():
-                       self.session.nav.playService(lastservice)
                        self.servicelist.setCurrent(lastservice)
+                       self.session.nav.playService(lastservice)
 
        def onShow(self):
                ref = self.session.nav.getCurrentlyPlayingServiceReference()
@@ -518,6 +542,87 @@ class ChannelSelection(ChannelSelectionBase, ChannelSelectionEdit):
                if lastservice.valid() and self.getCurrentSelection() != lastservice:
                        self.servicelist.setCurrent(lastservice)
 
+class ChannelSelectionRadio(ChannelSelectionBase, ChannelSelectionEdit):
+       def __init__(self, session):
+               ChannelSelectionBase.__init__(self, session)
+               ChannelSelectionEdit.__init__(self)
+
+               config.radio = ConfigSubsection();
+               config.radio.lastservice = configElement("config.radio.lastservice", configText, "", 0);
+               config.radio.lastroot = configElement("config.radio.lastroot", configText, "", 0);
+               self.onLayoutFinish.append(self.onCreate)
+
+               class ChannelActionMap(NumberActionMap):
+                       def action(self, contexts, action):
+                               if not self.csel.enterBouquet(action):
+                                       NumberActionMap.action(self, contexts, action)
+               self["actions"] = ChannelActionMap(["ChannelSelectActions", "OkCancelActions", "ContextMenuActions", "TvRadioActions"],
+                       {
+                               "keyTV": self.closeRadio,
+                               "keyRadio": self.closeRadio,
+                               "contextMenu": self.doContext,
+                               "cancel": self.closeRadio,
+                               "ok": self.channelSelected,
+                               "showFavourites": self.showFavourites,
+                               "showAllServices": self.showAllServices,
+                               "showProviders": self.showProviders,
+                               "showSatellites": self.showSatellites,
+                               "1": self.keyNumberGlobal,
+                               "2": self.keyNumberGlobal,
+                               "3": self.keyNumberGlobal,
+                               "4": self.keyNumberGlobal,
+                               "5": self.keyNumberGlobal,
+                               "6": self.keyNumberGlobal,
+                               "7": self.keyNumberGlobal,
+                               "8": self.keyNumberGlobal,
+                               "9": self.keyNumberGlobal,
+                               "0": self.keyNumberGlobal
+                       })
+               self["actions"].csel = self
+
+       def onCreate(self):
+               self.setRadioMode()
+               lastroot=eServiceReference(config.radio.lastroot.value)
+               if lastroot.valid():
+                       self.setRoot(lastroot)
+               else:
+                       self.showFavourites()
+                       self.saveRoot(self.getRoot())
+               lastservice=eServiceReference(config.radio.lastservice.value)
+               if lastservice.valid():
+                       self.servicelist.setCurrent(lastservice)
+                       self.session.nav.playService(lastservice)
+                       self.servicelist.setPlayableIgnoreService(lastservice)
+
+       def channelSelected(self): # just return selected service
+               ref = self.getCurrentSelection()
+               if self.movemode:
+                       self.toggleMoveMarked()
+               elif (ref.flags & 7) == 7:
+                       self.setRoot(ref)
+               elif self.bouquet_mark_edit:
+                       self.doMark()
+               else:
+                       self.session.nav.playService(ref)
+                       self.servicelist.setPlayableIgnoreService(ref)
+                       config.radio.lastservice.value = ref.toString()
+                       config.radio.lastservice.save()
+
+       def setRoot(self, root, justSet=False):
+               self.setRootBase(root, justSet)
+
+       def closeRadio(self):
+               lastroot=eServiceReference(config.radio.lastroot.value)
+               lastservice=eServiceReference(config.radio.lastservice.value)
+               if lastroot.valid() and self.getRoot() != lastroot:
+                       self.setRoot(lastroot)
+               if lastservice.valid() and self.getCurrentSelection() != lastservice:
+                       self.servicelist.setCurrent(lastservice)
+               #set previous tv service
+               lastservice=eServiceReference(config.tv.lastservice.value)
+               self.session.nav.playService(lastservice)
+               self.close(None)
+
 class SimpleChannelSelection(ChannelSelectionBase):
        def __init__(self, session, title):
                ChannelSelectionBase.__init__(self, session)
@@ -528,7 +633,7 @@ class SimpleChannelSelection(ChannelSelectionBase):
                        def action(self, contexts, action):
                                if not self.csel.enterBouquet(action):
                                        NumberActionMap.action(self, contexts, action)
-               self["actions"] = ChannelActionMap(["ChannelSelectActions", "OkCancelActions", "ContextMenuActions"],
+               self["actions"] = ChannelActionMap(["ChannelSelectActions", "OkCancelActions", "ContextMenuActions", "TvRadioActions"],
                        {
                                "cancel": self.cancel,
                                "ok": self.channelSelected,
@@ -536,6 +641,8 @@ class SimpleChannelSelection(ChannelSelectionBase):
                                "showAllServices": self.showAllServices,
                                "showProviders": self.showProviders,
                                "showSatellites": self.showSatellites,
+                               "keyRadio": self.setModeRadio,
+                               "keyTV": self.setModeTv,
                                "1": self.keyNumberGlobal,
                                "2": self.keyNumberGlobal,
                                "3": self.keyNumberGlobal,
@@ -550,14 +657,24 @@ class SimpleChannelSelection(ChannelSelectionBase):
                self["actions"].csel = self
 
        def onExecCallback(self):
-               print "onExecCallback"
-               self.showFavourites()
                self.session.currentDialog.instance.setTitle(self.title)
+               self.setModeTv()
 
        def channelSelected(self): # just return selected service
                ref = self.getCurrentSelection()
-               self.close(ref)
+               if (ref.flags & 7) == 7:
+                       self.setRoot(ref)
+               else:
+                       ref = self.getCurrentSelection()
+                       self.close(ref)
 
-       def setRoot(self, root):
-               self.setRootBase(root)
+       def setRoot(self, root, justSet=False):
+               self.setRootBase(root, justSet)
 
+       def setModeTv(self):
+               self.setTvMode()
+               self.showFavourites()
+
+       def setModeRadio(self):
+               self.setRadioMode()
+               self.showFavourites()
index aaa3debace3b2857b9ad629856a3a04a3292542c..c2616dab0355e9507dc3b3b9212570b8add90a20 100644 (file)
@@ -1,6 +1,7 @@
 from Screen import Screen
 
 from Screens.MovieSelection import MovieSelection
+from Screens.ChannelSelection import ChannelSelectionRadio
 from Screens.MessageBox import MessageBox
 from ServiceReference import ServiceReference
 
@@ -33,20 +34,26 @@ class InfoBar(Screen, InfoBarVolumeControl, InfoBarShowHide, InfoBarPowerKey,
 
                self["actions"] = HelpableActionMap(self, "InfobarActions",
                        {
-                               "showMovies": (self.showMovies, _("Play recorded movies..."))
+                               "showMovies": (self.showMovies, _("Play recorded movies...")),
+                               "showRadio": (self.showRadio, _("Show the radio player..."))
                        })
                
                for x in HelpableScreen, \
                                InfoBarVolumeControl, InfoBarShowHide, InfoBarPowerKey, \
                                InfoBarNumberZap, InfoBarChannelSelection, InfoBarMenu, InfoBarEPG, \
                                InfoBarEvent, InfoBarServiceName, InfoBarInstantRecord, InfoBarAudioSelection, \
-                               InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish, InfoBarSubserviceSelection, InfoBarTuner:
+                               InfoBarAdditionalInfo, InfoBarNotifications, InfoBarDish, InfoBarSubserviceSelection, \
+                               InfoBarTuner:
                        x.__init__(self)
 
                self.helpList.append((self["actions"], "InfobarActions", [("showMovies", "Watch a Movie...")]))
+               self.helpList.append((self["actions"], "InfobarActions", [("showRadio", "Hear Radio...")]))
 
                self["CurrentTime"] = Clock()
 
+       def showRadio(self):
+               self.session.open(ChannelSelectionRadio)
+
        def showMovies(self):
                self.session.openWithCallback(self.movieSelected, MovieSelection)