1 #######################################################################
3 # EasyMedia for Dreambox-Enigma2
4 # Coded by Vali (c)2010
5 # Support: www.dreambox-tools.info
8 # This plugin is licensed under the Creative Commons
9 # Attribution-NonCommercial-ShareAlike 3.0 Unported License.
10 # To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/
11 # or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
13 # Alternatively, this plugin may be distributed and executed on hardware which
14 # is licensed by Dream Multimedia GmbH.
17 # This plugin is NOT free software. It is open source, you are allowed to
18 # modify it (if you keep the license), but it may not be commercially
19 # distributed other than under the conditions noted above.
22 #######################################################################
26 from __init__ import _
27 from Screens.Screen import Screen
28 from Screens.MessageBox import MessageBox
29 from Screens.InfoBarGenerics import InfoBarPlugins
30 from Screens.InfoBar import InfoBar
31 from Screens.ChoiceBox import ChoiceBox
32 from Plugins.Plugin import PluginDescriptor
33 from Components.ActionMap import ActionMap
34 from Components.MenuList import MenuList
35 from Components.ConfigList import ConfigListScreen
36 from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigSelection
37 from Tools.Directories import fileExists
38 from Tools.LoadPixmap import LoadPixmap
39 from enigma import RT_HALIGN_LEFT, eListboxPythonMultiContent, gFont, getDesktop
43 EMbaseInfoBarPlugins__init__ = None
44 EMStartOnlyOneTime = False
46 InfoBar_instance = None
50 config.plugins.easyMedia = ConfigSubsection()
51 config.plugins.easyMedia.music = ConfigSelection(default="mediaplayer", choices = [("no", _("Disabled")), ("mediaplayer", _("MediaPlayer")), ("merlinmp", _("MerlinMusicPlayer"))])
52 config.plugins.easyMedia.files = ConfigSelection(default="dreamexplorer", choices = [("no", _("Disabled")), ("filebrowser", _("Filebrowser")), ("dreamexplorer", _("DreamExplorer")), ("tuxcom", _("TuxCom"))])
53 config.plugins.easyMedia.bookmarks = ConfigSelection(default="no", choices = [("no", _("Disabled")), ("yes", _("Enabled"))])
54 config.plugins.easyMedia.mytube = ConfigSelection(default="no", choices = [("no", _("Disabled")), ("yes", _("Enabled"))])
55 config.plugins.easyMedia.vlc = ConfigSelection(default="no", choices = [("no", _("Disabled")), ("yes", _("Enabled"))])
56 config.plugins.easyMedia.dvd = ConfigSelection(default="no", choices = [("no", _("Disabled")), ("yes", _("Enabled"))])
57 config.plugins.easyMedia.weather = ConfigSelection(default="yes", choices = [("no", _("Disabled")), ("yes", _("Enabled"))])
58 config.plugins.easyMedia.iradio = ConfigSelection(default="no", choices = [("no", _("Disabled")), ("yes", _("Enabled"))])
59 config.plugins.easyMedia.idream = ConfigSelection(default="no", choices = [("no", _("Disabled")), ("yes", _("Enabled"))])
60 config.plugins.easyMedia.zdfmedia = ConfigSelection(default="no", choices = [("no", _("Disabled")), ("yes", _("Enabled"))])
64 def Plugins(**kwargs):
65 return [PluginDescriptor(where = PluginDescriptor.WHERE_SESSIONSTART, fnc = EasyMediaAutostart),
66 PluginDescriptor(name="EasyMedia", description=_("Not easy way to start EasyMedia"), where = PluginDescriptor.WHERE_PLUGINMENU, fnc=notEasy),]
70 def EasyMediaAutostart(reason, **kwargs):
71 global EMbaseInfoBarPlugins__init__
72 if "session" in kwargs:
74 EMsession = kwargs["session"]
75 if EMbaseInfoBarPlugins__init__ is None:
76 EMbaseInfoBarPlugins__init__ = InfoBarPlugins.__init__
77 InfoBarPlugins.__init__ = InfoBarPlugins__init__
78 InfoBarPlugins.pvr = pvr
82 def InfoBarPlugins__init__(self):
83 global EMStartOnlyOneTime
84 if not EMStartOnlyOneTime:
85 EMStartOnlyOneTime = True
86 global InfoBar_instance
87 InfoBar_instance = self
88 self["EasyMediaActions"] = ActionMap(["EasyMediaActions"],
89 {"video_but": self.pvr}, -1)
91 InfoBarPlugins.__init__ = InfoBarPlugins.__init__
92 InfoBarPlugins.pvr = None
93 EMbaseInfoBarPlugins__init__(self)
98 self.session.openWithCallback(MPcallbackFunc, EasyMedia)
102 def notEasy(session, **kwargs):
103 session.openWithCallback(MPcallbackFunc, EasyMedia)
107 def MPanelEntryComponent(key, text):
109 res.append((eListboxPythonMultiContent.TYPE_TEXT, 160, 15, 300, 60, 0, RT_HALIGN_LEFT, text[0]))
110 png = LoadPixmap('/usr/lib/enigma2/python/Plugins/Extensions/EasyMedia/' + key + ".png")
112 res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, 30, 5, 100, 50, png))
117 class MPanelList(MenuList):
118 def __init__(self, list, selection = 0, enableWrapAround=True):
119 MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
120 self.l.setFont(0, gFont("Regular", 24))
121 self.l.setItemHeight(60)
122 self.selection = selection
123 def postWidgetCreate(self, instance):
124 MenuList.postWidgetCreate(self, instance)
125 self.moveToIndex(self.selection)
129 def BookmarksCallback(choice):
130 choice = choice and choice[1]
132 config.movielist.last_videodir.value = choice
133 config.movielist.last_videodir.save()
135 InfoBar_instance.showMovies()
139 class ConfigEasyMedia(ConfigListScreen, Screen):
141 <screen name="ConfigEasyMedia" position="center,center" size="600,410" title="EasyMedia settings...">
142 <widget name="config" position="5,5" scrollbarMode="showOnDemand" size="590,380"/>
143 <eLabel font="Regular;20" foregroundColor="#00ff4A3C" halign="center" position="20,388" size="120,26" text="Cancel"/>
144 <eLabel font="Regular;20" foregroundColor="#0056C856" halign="center" position="165,388" size="120,26" text="Save"/>
146 def __init__(self, session):
147 Screen.__init__(self, session)
148 self.setTitle(_("EasyMedia settings..."))
150 list.append(getConfigListEntry(_("Music player:"), config.plugins.easyMedia.music))
151 list.append(getConfigListEntry(_("Files browser:"), config.plugins.easyMedia.files))
152 list.append(getConfigListEntry(_("Show bookmarks:"), config.plugins.easyMedia.bookmarks))
153 list.append(getConfigListEntry(_("YouTube player:"), config.plugins.easyMedia.mytube))
154 list.append(getConfigListEntry(_("VLC player:"), config.plugins.easyMedia.vlc))
155 list.append(getConfigListEntry(_("DVD player:"), config.plugins.easyMedia.dvd))
156 list.append(getConfigListEntry(_("Weather plugin:"), config.plugins.easyMedia.weather))
157 list.append(getConfigListEntry(_("NetRadio player:"), config.plugins.easyMedia.iradio))
158 list.append(getConfigListEntry(_("Show Merlin-iDream:"), config.plugins.easyMedia.idream))
159 list.append(getConfigListEntry(_("ZDFmediathek player:"), config.plugins.easyMedia.zdfmedia))
160 ConfigListScreen.__init__(self, list)
161 self["actions"] = ActionMap(["OkCancelActions", "ColorActions"], {"green": self.save, "red": self.exit, "cancel": self.exit}, -1)
164 for x in self["config"].list:
169 for x in self["config"].list:
175 class EasyMedia(Screen):
176 sz_w = getDesktop(0).size().width()
179 <screen flags="wfNoBorder" position="0,0" size="450,720" title="Easy Media">
180 <ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyMedia/bg.png" position="0,0" size="450,576"/>
181 <ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyMedia/bg.png" position="0,576" size="450,145"/>
182 <widget name="list" position="60,30" size="350,660" scrollbarMode="showNever" transparent="1" zPosition="2"/>
186 <screen flags="wfNoBorder" position="-20,0" size="450,576" title="Easy Media">
187 <ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyMedia/bg.png" position="0,0" size="450,576"/>
188 <widget name="list" position="70,48" size="320,480" scrollbarMode="showNever" transparent="1" zPosition="2"/>
192 <screen position="center,center" size="320,440" title="Easy Media">
193 <widget name="list" position="10,10" size="300,420" scrollbarMode="showOnDemand" />
195 def __init__(self, session):
196 Screen.__init__(self, session)
197 self.session = session
202 self.__keys.append("movies")
203 MPaskList.append((_("Movies"), "PLAYMOVIES"))
204 if config.plugins.easyMedia.bookmarks.value != "no":
205 self.__keys.append("bookmarks")
206 MPaskList.append((_("Bookmarks"), "BOOKMARKS"))
208 self.__keys.append("pictures")
209 MPaskList.append((_("Pictures"), "PICTURES"))
210 if config.plugins.easyMedia.music.value != "no":
211 self.__keys.append("music")
212 MPaskList.append((_("Music"), "MUSIC"))
213 if config.plugins.easyMedia.dvd.value != "no":
214 self.__keys.append("dvd")
215 MPaskList.append((_("DVD Player"), "DVD"))
216 if config.plugins.easyMedia.weather.value != "no":
217 self.__keys.append("weather")
218 MPaskList.append((_("Weather"), "WEATHER"))
219 if config.plugins.easyMedia.files.value != "no":
220 self.__keys.append("files")
221 MPaskList.append((_("Files"), "FILES"))
222 if config.plugins.easyMedia.iradio.value != "no":
223 self.__keys.append("shoutcast")
224 MPaskList.append((_("SHOUTcast"), "SHOUTCAST"))
225 if config.plugins.easyMedia.idream.value != "no":
226 self.__keys.append("idream")
227 MPaskList.append((_("iDream"), "IDREAM"))
228 if config.plugins.easyMedia.mytube.value != "no":
229 self.__keys.append("mytube")
230 MPaskList.append((_("MyTube Player"), "MYTUBE"))
231 if config.plugins.easyMedia.vlc.value != "no":
232 self.__keys.append("vlc")
233 MPaskList.append((_("VLC Player"), "VLC"))
234 if config.plugins.easyMedia.zdfmedia.value != "no":
235 self.__keys.append("zdf")
236 MPaskList.append((_("ZDFmediathek"), "ZDF"))
240 strpos = str(self.__keys[pos])
241 self.list.append(MPanelEntryComponent(key = strpos, text = x))
242 if self.__keys[pos] != "":
243 self.keymap[self.__keys[pos]] = MPaskList[pos]
245 self["list"] = MPanelList(list = self.list, selection = 0)
246 self["actions"] = ActionMap(["WizardActions", "MenuActions"],
250 "menu": self.emContextMenu
257 cursel = self["list"].l.getCurrentSelection()
259 self.goEntry(cursel[0])
263 def goEntry(self, entry):
264 if len(entry) > 2 and isinstance(entry[1], str) and entry[1] == "CALLFUNC":
265 arg = self["list"].l.getCurrentSelection()[0]
270 def emContextMenu(self):
271 self.session.open(ConfigEasyMedia)
275 def MPcallbackFunc(answer):
276 answer = answer and answer[1]
277 if answer == "PLAYMOVIES":
279 InfoBar_instance.showMovies()
280 elif answer == "BOOKMARKS":
281 tmpBookmarks = config.movielist.videodirs
282 myBookmarks = tmpBookmarks and tmpBookmarks.value[:] or []
283 if len(myBookmarks)>0:
285 for s in myBookmarks:
287 EMsession.openWithCallback(BookmarksCallback, ChoiceBox, title=_("Select bookmark..."), list = askBM)
288 elif answer == "PICTURES":
289 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/PicturePlayer/plugin.pyo"):
290 from Plugins.Extensions.PicturePlayer.plugin import picshow
291 EMsession.open(picshow)
293 EMsession.open(MessageBox, text = _('Picture-player is not installed!'), type = MessageBox.TYPE_ERROR)
294 elif answer == "MUSIC":
295 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/MerlinMusicPlayer/plugin.pyo") and (config.plugins.easyMedia.music.value == "merlinmp"):
296 from Plugins.Extensions.MerlinMusicPlayer.plugin import MerlinMusicPlayerFileList
298 EMsession.open(MerlinMusicPlayerFileList, servicelist)
299 elif fileExists("/usr/lib/enigma2/python/Plugins/Extensions/MediaPlayer/plugin.pyo") and (config.plugins.easyMedia.music.value == "mediaplayer"):
300 from Plugins.Extensions.MediaPlayer.plugin import MediaPlayer
301 EMsession.open(MediaPlayer)
303 EMsession.open(MessageBox, text = _('No Music-Player installed!'), type = MessageBox.TYPE_ERROR)
304 elif answer == "FILES":
305 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/Tuxcom/plugin.pyo") and (config.plugins.easyMedia.files.value == "tuxcom"):
306 from Plugins.Extensions.Tuxcom.plugin import TuxComStarter
307 EMsession.open(TuxComStarter)
308 elif fileExists("/usr/lib/enigma2/python/Plugins/Extensions/DreamExplorer/plugin.pyo") and (config.plugins.easyMedia.files.value == "dreamexplorer"):
309 from Plugins.Extensions.DreamExplorer.plugin import DreamExplorerII
310 EMsession.open(DreamExplorerII)
311 elif fileExists("/usr/lib/enigma2/python/Plugins/Extensions/Filebrowser/plugin.pyo") and (config.plugins.easyMedia.files.value == "filebrowser"):
312 from Plugins.Extensions.Filebrowser.plugin import FilebrowserScreen
313 EMsession.open(FilebrowserScreen)
315 EMsession.open(MessageBox, text = _('No File-Manager installed!'), type = MessageBox.TYPE_ERROR)
316 elif answer == "WEATHER":
317 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/WeatherPlugin/plugin.pyo"):
318 from Plugins.Extensions.WeatherPlugin.plugin import WeatherPlugin
319 EMsession.open(WeatherPlugin)
321 EMsession.open(MessageBox, text = _('Weather Plugin is not installed!'), type = MessageBox.TYPE_ERROR)
322 elif answer == "DVD":
323 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/DVDPlayer/plugin.pyo"):
324 from Plugins.Extensions.DVDPlayer.plugin import DVDPlayer
325 EMsession.open(DVDPlayer)
327 EMsession.open(MessageBox, text = _('DVDPlayer Plugin is not installed!'), type = MessageBox.TYPE_ERROR)
328 elif answer == "MYTUBE":
329 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/MyTube/plugin.pyo"):
330 from Plugins.Extensions.MyTube.plugin import *
331 MyTubeMain(EMsession)
333 EMsession.open(MessageBox, text = _('MyTube Plugin is not installed!'), type = MessageBox.TYPE_ERROR)
334 elif answer == "SHOUTCAST":
335 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/SHOUTcast/plugin.pyo"):
336 from Plugins.Extensions.SHOUTcast.plugin import SHOUTcastWidget
337 EMsession.open(SHOUTcastWidget)
339 EMsession.open(MessageBox, text = _('SHOUTcast Plugin is not installed!'), type = MessageBox.TYPE_ERROR)
340 elif answer == "ZDF":
341 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/ZDFMediathek/plugin.pyo"):
342 from Plugins.Extensions.ZDFMediathek.plugin import ZDFMediathek
343 EMsession.open(ZDFMediathek)
345 EMsession.open(MessageBox, text = _('ZDFmediathek Plugin is not installed!'), type = MessageBox.TYPE_ERROR)
346 elif answer == "VLC":
347 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/VlcPlayer/plugin.pyo"):
348 from Plugins.Extensions.VlcPlayer.plugin import *
351 EMsession.open(MessageBox, text = _('VLC Player is not installed!'), type = MessageBox.TYPE_ERROR)
352 elif answer == "IDREAM":
353 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/MerlinMusicPlayer/plugin.pyo"):
354 from Plugins.Extensions.MerlinMusicPlayer.plugin import iDreamMerlin
356 EMsession.open(iDreamMerlin, servicelist)
358 EMsession.open(MessageBox, text = _('Merlin iDream is not installed!'), type = MessageBox.TYPE_ERROR)