示例#1
0
	def onFinish(self):
		self['rating10'].setValue(0)
		self.urlfsk = "https://altersfreigaben.de/api/tmdb_id/"+str(self.id)
		getPage(self.urlfsk).addCallback(self.getDataFSK).addErrback(self.dataError)
		self['searchinfo'].setText(_('Loading information for "%s"') % self.mname)
		getPage(self.url).addCallback(self.getData).addErrback(self.dataError)
		CoverHelper(self['coverArt']).getCover(self.cover)
示例#2
0
    def __init__(
        self, session, playList, playIdx, listTitle=None, plType="local", title_inr=0, queue=None, mp_event=None
    ):
        self.session = session

        self.plugin_path = mp_globals.pluginPath
        self.skin_path = mp_globals.pluginPath + "/skins"

        path = "%s/%s/showSongstoAll.xml" % (self.skin_path, config.mediaportal.skin.value)
        if not fileExists(path):
            path = self.skin_path + "/original/showSongstoAll.xml"

        with open(path, "r") as f:
            self.skin = f.read()
            f.close()

        Screen.__init__(self, session)

        self["actions"] = ActionMap(
            ["OkCancelActions", "MediaPlayerSeekActions", "EPGSelectActions", "ColorActions", "InfobarActions"],
            {"cancel": self.exit, "red": self.red, "ok": self.ok},
            -2,
        )

        self.playList = playList
        self.playIdx = playIdx
        self.listTitle = listTitle
        self.plType = plType
        self.title_inr = title_inr
        self.playlistQ = queue
        self.event = mp_event

        self["title"] = Label("")
        self["coverArt"] = Pixmap()
        self._Cover = CoverHelper(self["coverArt"])
        self["songtitle"] = Label("")
        self["artist"] = Label("")
        self["album"] = Label("")
        if self.plType == "global":
            self["F1"] = Label("Löschen")
        else:
            self["F1"] = Label("")
        self["F2"] = Label("")
        self["F3"] = Label("")
        self["F4"] = Label("")

        # self.updateTimer = eTimer()
        # self.updateTimer.callback.append(self.updateStatus)

        self.chooseMenuList = MenuList([], enableWrapAround=True, content=eListboxPythonMultiContent)
        self.chooseMenuList.l.setFont(0, gFont("mediaportal", 23))
        self.chooseMenuList.l.setItemHeight(25)
        self["streamlist"] = self.chooseMenuList

        self.onClose.append(self.resetEvent)

        self.onLayoutFinish.append(self.showPlaylist)
 def loadPic(self):
     if self.picQ.empty():
         self.eventP.clear()
         return
     while not self.picQ.empty():
         self.picQ.get_nowait()
     streamName = self['liste'].getCurrent()[0][0]
     self['name'].setText(streamName)
     streamPic = self['liste'].getCurrent()[0][2]
     self.showInfos()
     self.updateP = 1
     CoverHelper(self['coverArt'],
                 self.ShowCoverFileExit).getCover(streamPic)
示例#4
0
class SimplePlayer(Screen, SimpleSeekHelper, SimplePlayerResume, InfoBarMenu, InfoBarBase, InfoBarSeek, InfoBarNotifications, InfoBarServiceNotifications, InfoBarPVRState, InfoBarShowHide, InfoBarAudioSelection, InfoBarSubtitleSupport, InfoBarSimpleEventView):
	ALLOW_SUSPEND = True

	def __init__(self, session, playList, playIdx=0, playAll=False, listTitle=None, plType='local', title_inr=0, cover=False, ltype='', autoScrSaver=False, showPlaylist=True, listEntryPar=None, playList2=[], playerMode='VIDEO'):
		try:
			from enigma import eServiceMP3
		except:
			is_eServiceMP3 = False
			print "No MP3 service"
		else:
			is_eServiceMP3 = True
			print "MP3 service imported"

		Screen.__init__(self, session)
		print "SimplePlayer:"
		self.session = session
		self.plugin_path = "/usr/lib/enigma2/python/Plugins/Extensions/supportchannel"
		self.skin_path = "/usr/lib/enigma2/python/Plugins/Extensions/supportchannel" + "/skins"
		self.wallicon_path = "/usr/lib/enigma2/python/Plugins/Extensions/supportchannel" + "/icons_wall/"

		path = "%s/simpleplayer/SimplePlayer.xml" % self.skin_path
		with open(path, "r") as f:
			self.skin = f.read()
			f.close()

		self.setActionPrio()
		self["actions"] = ActionMap(["WizardActions",'MediaPlayerSeekActions',"EPGSelectActions",'MoviePlayerActions','ColorActions','InfobarActions',"MenuActions","HelpActions"],
		{
			"leavePlayer": self.leavePlayer,
			config.supportchannel.sp_mi_key.value: self.openMediainfo,
			"menu":		self.openMenu,
			"up": 		self.openPlaylist,
			"down":		self.randomNow,
			"back":		self.leavePlayer,
			"left":		self.seekBack,
			"right":	self.seekFwd,
			"seekdef:1": self.Key1,
			"seekdef:3": self.Key3,
			"seekdef:4": self.Key4,
			"seekdef:6": self.Key6,
			"seekdef:7": self.Key7,
			"seekdef:9": self.Key9

		}, self.action_prio)

		SimpleSeekHelper.__init__(self)
		SimplePlayerResume.__init__(self)
		InfoBarMenu.__init__(self)
		InfoBarNotifications.__init__(self)
		InfoBarServiceNotifications.__init__(self)
		InfoBarBase.__init__(self)
		InfoBarShowHide.__init__(self)
		InfoBarAudioSelection.__init__(self)
		InfoBarSubtitleSupport.__init__(self)
		InfoBarSimpleEventView.__init__(self)

		self.allowPiP = False
		InfoBarSeek.__init__(self)
		InfoBarPVRState.__init__(self)

		self.skinName = 'MediaPortal SimplePlayer'
		self.lastservice = self.session.nav.getCurrentlyPlayingServiceReference()

		self.playerMode = playerMode
		self.keyPlayNextLocked = False
		self.isTSVideo = False
		self.showGlobalPlaylist = True
		self.showPlaylist = showPlaylist
		self.scrSaver = ''
		self.saverActive = False
		self.autoScrSaver = autoScrSaver
		self.pl_open = False
		self.playMode = [str(config.supportchannel.sp_playmode.value)]
		self.listTitle = listTitle
		self.playAll = playAll
		self.playList = playList
		self.playIdx = playIdx
		if plType == 'local':
			self.playLen = len(playList)
		else:
			self.playLen = len(playList2)

		self.listEntryPar=listEntryPar
		self.returning = False
		self.pl_entry = ['', '', '', '', '', '', '', '', '']
		self.plType = plType
		self.playList2 = playList2
		self.pl_name = 'mp_global_pl_%02d' % config.supportchannel.sp_pl_number.value
		self.title_inr = title_inr
		self.cover = cover
		self.ltype = ltype
		self.playlistQ = Queue.Queue(0)
		self.pl_status = (0, '', '', '', '', '')
		self.pl_event = SimpleEvent()
		self['spcoverframe'] = Pixmap()
		self['spcoverfg'] = Pixmap()
		self['Icon'] = Pixmap()
		self._Icon = CoverHelper(self['Icon'])
		self['premiumizemeoff'] = Pixmap()
		self['premiumizemeon'] = Pixmap()
		self['premiumizemeon'].hide()

		# load default cover
		self['Cover'] = Pixmap()
		self._Cover = CoverHelper(self['Cover'], nc_callback=self.hideSPCover)
		self.coverBGisHidden = False
		self.cover2 = False

		self.SaverTimer = eTimer()
		self.SaverTimer.callback.append(self.openSaver)

		self.hideSPCover()
		self.configSaver()
		self.onClose.append(self.playExit)
		self.onFirstExecBegin.append(self.showIcon)
		self.onFirstExecBegin.append(self.playVideo)

		if self.playerMode in 'MP3':
			self.onFirstExecBegin.append(self.openPlaylist)

		if is_eServiceMP3:
			self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
				{
					eServiceMP3.evAudioDecodeError: self.__evAudioDecodeError,
					eServiceMP3.evVideoDecodeError: self.__evVideoDecodeError,
					eServiceMP3.evPluginError: self.__evPluginError,
					eServiceMP3.evStreamingSrcError: self.__evStreamingSrcError
				})

	def __evAudioDecodeError(self):
		if not config.supportchannel.sp_show_errors.value:
			return
		from Screens.MessageBox import MessageBox
		from enigma import iServiceInformation
		currPlay = self.session.nav.getCurrentService()
		sTagAudioCodec = currPlay.info().getInfoString(iServiceInformation.sTagAudioCodec)
		print "[__evAudioDecodeError] audio-codec %s can't be decoded by hardware" % (sTagAudioCodec)
		self.session.open(MessageBox, _("This STB can't decode %s streams!") % sTagAudioCodec, type = MessageBox.TYPE_INFO,timeout = 10 )

	def __evVideoDecodeError(self):
		if not config.supportchannel.sp_show_errors.value:
			return
		from Screens.MessageBox import MessageBox
		from enigma import iServiceInformation
		currPlay = self.session.nav.getCurrentService()
		sTagVideoCodec = currPlay.info().getInfoString(iServiceInformation.sTagVideoCodec)
		print "[__evVideoDecodeError] video-codec %s can't be decoded by hardware" % (sTagVideoCodec)
		self.session.open(MessageBox, _("This STB can't decode %s streams!") % sTagVideoCodec, type = MessageBox.TYPE_INFO,timeout = 10 )

	def __evPluginError(self):
		if not config.supportchannel.sp_show_errors.value:
			return
		from Screens.MessageBox import MessageBox
		from enigma import iServiceInformation
		currPlay = self.session.nav.getCurrentService()
		message = currPlay.info().getInfoString(iServiceInformation.sUser+12)
		print "[__evPluginError]" , message
		self.session.open(MessageBox, message, type = MessageBox.TYPE_INFO,timeout = 10 )

	def __evStreamingSrcError(self):
		if not config.supportchannel.sp_show_errors.value:
			return
		from Screens.MessageBox import MessageBox
		from enigma import iServiceInformation
		currPlay = self.session.nav.getCurrentService()
		message = currPlay.info().getInfoString(iServiceInformation.sUser+12)
		print "[__evStreamingSrcError]", message
		self.session.open(MessageBox, _("Streaming error: %s") % message, type = MessageBox.TYPE_INFO,timeout = 10 )

	def playVideo(self):
		print "playVideo:"
		self.isTSVideo = False
		if self.seekBarLocked:
			self.cancelSeek()
		self.resetMySpass()
		if self.plType == 'global':
			self.getVideo2()
		else:
			self.cover2 = False
			self.getVideo()

	def playSelectedVideo(self, idx):
		self.playIdx = idx
		self.playVideo()

	def dataError(self, error):
		print "dataError:"
		printl(error,self,"E")
		if config.supportchannel.sp_show_errors.value:
			self.session.openWithCallback(self.dataError2, MessageBox, str(error), MessageBox.TYPE_INFO, timeout=10)
		else:
			reactor.callLater(2, self.dataError2, None)

	def dataError2(self, res):
		self.playNextStream(config.supportchannel.sp_on_movie_eof.value)

	def playStream(self, title, url=None, album='', artist='', imgurl=''):
		print "playStream: ",title,url
		if not url:
			return

		if mp_globals.proxy:
			self['premiumizemeoff'].hide()
			self['premiumizemeon'].show()
			mp_globals.proxy = False
		else:
			self['premiumizemeon'].hide()
			self['premiumizemeoff'].show()

		if self.cover or self.cover2:
			self.showCover(imgurl)

		if url.endswith('.ts'):
			sref = eServiceReference(0x0001, 0, url)
			self.isTSVideo = True
		else:
			sref = eServiceReference(0x1001, 0, url)
			self.isTSVideo = False

		pos = title.find('. ', 0, 5)
		if pos > 0:
			pos += 2
			title = title[pos:]

		if artist != '':
			video_title = artist + ' - ' + title
		else:
			video_title = title
		sref.setName(video_title)

		if self.cover:
			cflag = '1'
		else:
			cflag = '0'

		self.pl_entry = [title, None, artist, album, self.ltype, '', imgurl, cflag]

		self.stopPlayPositionTracker()

		self.session.nav.stopService()
		self.session.nav.playService(sref)

		if len(video_title) > 0:
			lru_key = video_title
		else:
			lru_key = url
		self.initPlayPositionTracker(lru_key)

		self.pl_status = (self.playIdx, title, artist, album, imgurl, self.plType)
		if self.pl_open:
			self.playlistQ.put(self.pl_status)
			self.pl_event.genEvent()

		self.keyPlayNextLocked = False


	def playPrevStream(self, value):
		print "_prevStream:"
		if not self.playAll or self.playLen <= 1:
			self.handleLeave(value)
		else:
			if self.playIdx > 0:
				self.playIdx -= 1
			else:
				self.playIdx = self.playLen - 1
			self.playVideo()

	def playNextStream(self, value):
		print "playNextStream:"
		if not self.playAll or self.playLen <= 1:
			self.handleLeave(value)
		else:
			if self.playIdx in range(0, self.playLen-1):
				self.playIdx += 1
			else:
				self.playIdx = 0
			self.playVideo()

	def playRandom(self, value):
		print 'playRandom:'
		if self.playLen > 1 and self.playAll:
			self.playIdx = random.randint(0, self.playLen-1)
			self.playVideo()
		else:
			self.handleLeave(value)

	def randomNow(self):
		if self.playAll:
			self.playRandom(config.supportchannel.sp_on_movie_stop.value)

	def seekFwd(self):
		if self.isTSVideo:
			InfoBarSeek.seekFwd(self)
		elif self.seekBarShown and not self.seekBarLocked:
			self.initSeek()
		elif self.seekBarLocked:
			self.seekRight()
		elif self.playAll and not self.keyPlayNextLocked:
			self.keyPlayNextLocked = True
			self.playNextStream(config.supportchannel.sp_on_movie_stop.value)

	def seekBack(self):
		if self.isTSVideo:
			InfoBarSeek.seekBack(self)
		elif self.seekBarShown and not self.seekBarLocked:
			self.initSeek()
		elif self.seekBarLocked:
			self.seekLeft()
		elif self.playAll and not self.keyPlayNextLocked:
			self.keyPlayNextLocked = True
			self.playPrevStream(config.supportchannel.sp_on_movie_stop.value)

	def Key1(self):
		self.isNumberSeek = True
		self.initSeek()
		self.numberKeySeek(-int(config.seek.selfdefined_13.value))

	def Key3(self):
		self.isNumberSeek = True
		self.initSeek()
		self.numberKeySeek(int(config.seek.selfdefined_13.value))

	def Key4(self):
		self.isNumberSeek = True
		self.initSeek()
		self.numberKeySeek(-int(config.seek.selfdefined_46.value))

	def Key6(self):
		self.isNumberSeek = True
		self.initSeek()
		self.numberKeySeek(int(config.seek.selfdefined_46.value))

	def Key7(self):
		self.isNumberSeek = True
		self.initSeek()
		self.numberKeySeek(-int(config.seek.selfdefined_79.value))

	def Key9(self):
		self.isNumberSeek = True
		self.initSeek()
		self.numberKeySeek(int(config.seek.selfdefined_79.value))

	def handleLeave(self, how):
		print "handleLeave:"
		if self.playerMode in 'MP3':
			self.openPlaylist()
			return
		self.is_closing = True
		if how == "ask":
			if self.plType == 'local':
				list = (
					(_("Ja"), "quit"),
					("Ja & Service zur glob. Playlist-%02d hinzufügen" % config.supportchannel.sp_pl_number.value, "add"),
					(_("Nein"), "continue"),
					(_("Nein, aber von Anfang an neu beginnen"), "restart")
				)
			else:
				list = (
					(_("Ja"), "quit"),
					(_("Nein"), "continue"),
					(_("Nein, aber von Anfang an neu beginnen"), "restart")
				)

			from Screens.ChoiceBox import ChoiceBox
			self.session.openWithCallback(self.leavePlayerConfirmed, ChoiceBox, title=_("Stop playing this movie?"), list = list)
		else:
			self.leavePlayerConfirmed([True, how])

	def leavePlayerConfirmed(self, answer):
		print "leavePlayerConfirmed:"
		answer = answer and answer[1]
		print answer

		self.savePlayPosition()

		if answer in ("quit", "movielist"):
			self.close()
		elif answer == "restart":
			if self.isMySpass:
				self.restartMySpass()
			else:
				self.doSeek(0)
				self.setSeekState(self.SEEK_STATE_PLAY)
		elif answer == "add":
			self.addToPlaylist()
			self.close()

	def leavePlayer(self):
		print "leavePlayer:"
		if self.seekBarLocked:
			self.cancelSeek()
		else:
			self.handleLeave(config.supportchannel.sp_on_movie_stop.value)

	def doEofInternal(self, playing):
		print "doEofInt:"
		if playing:
			if not self.resumeEOF():
				if self.playMode[0] == 'random':
					self.playRandom(config.supportchannel.sp_on_movie_eof.value)
				elif self.playMode[0] == 'forward':
					self.playNextStream(config.supportchannel.sp_on_movie_eof.value)
				elif self.playMode[0] == 'backward':
					self.playPrevStream(config.supportchannel.sp_on_movie_eof.value)
			else:
				self.close()

	def playExit(self):
		print "playExit:"
		self.SaverTimer.stop()
		del self.SaverTimer
		if isinstance(self, SimpleSeekHelper):
			del self.cursorTimer
		if isinstance(self, SimplePlayerResume):
			del self.posTrackerTimer
			del self.eofResumeTimer

		if not self.playerMode in 'MP3':
			self.restoreLastService()

	def restoreLastService(self):
		if config.supportchannel.restorelastservice.value == "1":
			self.session.nav.playService(self.lastservice)
		else:
			self.session.nav.stopService()

	def getVideo(self):
		print "getVideo:"
		title = self.playList[self.playIdx][0]
		url = self.playList[self.playIdx][1]
		if len(self.playList[0]) == 3:
			iurl = self.playList[self.playIdx][2]
		else:
			iurl = ''
		self.playStream(title, url, imgurl=iurl)

	def getVideo2(self):
		print "getVideo2:"
		if self.playLen > 0:
			titel = self.playList2[self.playIdx][1]
			url = self.playList2[self.playIdx][2]
			album = self.playList2[self.playIdx][3]
			artist = self.playList2[self.playIdx][4]
			imgurl = self.playList2[self.playIdx][7]
			self.cover2 = self.playList2[self.playIdx][8] == '1' and self.plType == 'global'

			if len(self.playList2[self.playIdx]) < 6:
				ltype = ''
			else:
				ltype = self.playList2[self.playIdx][5]

			if ltype == 'youtube':
				YoutubeLink(self.session).getLink(self.playStream, self.dataError, titel, url, imgurl)
			elif ltype == 'putpattv':
				token = self.playList2[self.playIdx][6]
				PutpattvLink(self.session).getLink(self.playStream, self.dataError, titel, url, token, imgurl)
			elif ltype == 'myvideo':
				token = self.playList2[self.playIdx][6]
				MyvideoLink(self.session).getLink(self.playStream, self.dataError, titel, url, token, imgurl)
			elif ltype == 'songsto' and not url:
				token = self.playList2[self.playIdx][6]
				SongstoLink(self.session).getLink(self.playStream, self.dataError, titel, artist, album, token, imgurl)
			elif mechanizeModule and ltype == 'canna':
				CannaLink(self.session).getLink(self.playStream, self.dataError, titel, artist, album, url, imgurl)
			elif ltype == 'eighties':
				token = self.playList2[self.playIdx][6]
				EightiesLink(self.session).getLink(self.playStream, self.dataError, titel, artist, album, url, token, imgurl)
			elif ltype == 'mtv':
				MTVdeLink(self.session).getLink(self.playStream, self.dataError, titel, artist, url, imgurl)
			elif url:
				self.playStream(titel, url, album, artist, imgurl=imgurl)
		else:
			self.close()

	def openPlaylist(self, pl_class=SimplePlaylist):
		if  ((self.showGlobalPlaylist and self.plType == 'global') or self.showPlaylist) and self.playLen > 0:
			if self.playlistQ.empty():
				self.playlistQ.put(self.pl_status)
			self.pl_open = True
			self.pl_event.genEvent()

			if self.plType == 'local':
				self.session.openWithCallback(self.cb_Playlist, pl_class, self.playList, self.playIdx, self.playMode, listTitle=self.listTitle, plType=self.plType, title_inr=self.title_inr, queue=self.playlistQ, mp_event=self.pl_event, listEntryPar=self.listEntryPar, playFunc=self.playSelectedVideo,playerMode=self.playerMode)
			else:
				self.session.openWithCallback(self.cb_Playlist, pl_class, self.playList2, self.playIdx, self.playMode, listTitle=None, plType=self.plType, title_inr=0, queue=self.playlistQ, mp_event=self.pl_event, listEntryPar=self.listEntryPar,playFunc=self.playSelectedVideo,playerMode=self.playerMode)
		elif not self.playLen:
			self.session.open(MessageBox, _("Keine Einträge in der Playlist vorhanden!"), MessageBox.TYPE_INFO, timeout=5)

	def cb_Playlist(self, data):
		self.pl_open = False

		while not self.playlistQ.empty():
			t = self.playlistQ.get_nowait()

		if data[0] >= 0:
			self.playIdx = data[0]
			if self.plType == 'global':
				if data[1] == 'del':
					self.session.nav.stopService()
					SimplePlaylistIO.delEntry(self.pl_name, self.playList2, self.playIdx)
					self.playLen = len(self.playList2)
					if self.playIdx >= self.playLen:
						self.playIdx -= 1
					if self.playIdx < 0:
						self.close()
					else:
						self.openPlaylist()
			if not self.keyPlayNextLocked:
				self.keyPlayNextLocked = True
				self.playVideo()
		elif data[0] == -1 and self.playerMode in 'MP3':
				self.close()

	def openMediainfo(self):
		if MediainfoPresent:
			url = self.session.nav.getCurrentlyPlayingServiceReference().getPath()
			if url[:4] == "http":
				self.session.open(mediaInfo, True)

	def openMenu(self):
		self.session.openWithCallback(self.cb_Menu, SimplePlayerMenu, self.plType, self.showPlaylist or self.showGlobalPlaylist)

	def cb_Menu(self, data):
		print "cb_Menu:"
		if data != []:
			if data[0] == 1:
				self.playMode[0] = config.supportchannel.sp_playmode.value
				self.configSaver()
				if self.cover or self.cover2:
					self.showCover(self.pl_entry[6])
				self.pl_name = 'mp_global_pl_%02d' % config.supportchannel.sp_pl_number.value
			elif data[0] == 2:
				self.addToPlaylist()

			elif data[0] == 3:
				nm = self.pl_name
				pl_list = SimplePlaylistIO.getPL(nm)
				self.playList2 = pl_list
				playLen = len(self.playList2)
				if playLen > 0:
					self.playIdx = 0
					self.playLen = playLen
					self.plType = 'global'
				self.openPlaylist()

			elif data[0] == 4:
				if self.plType != 'local':
					playLen = len(self.playList)
					if playLen > 0:
						self.playIdx = 0
						self.playLen = playLen
						self.plType = 'local'
						self.playList2 = []
					self.openPlaylist()

			elif data[0] == 6:
				self.mainMenu()

	def addToPlaylist(self):
		if self.plType != 'local':
			self.session.open(MessageBox, _("Fehler: Service darf nur von der lok. PL hinzugefügt werden"), MessageBox.TYPE_INFO, timeout=5)
			return

		if self.pl_entry[4] == 'youtube':
			url = self.playList[self.playIdx][2]
		elif self.pl_entry[4] == 'myvideo':
			url = self.playList[self.playIdx][1]
			self.pl_entry[5] = self.playList[self.playIdx][2]
		elif self.pl_entry[4] == 'mtv':
			url = self.playList[self.playIdx][1]
		elif self.pl_entry[4] == 'putpattv' and self.playList[self.playIdx][2]:
			url = self.playList[self.playIdx][1]
			self.pl_entry[5] = self.playList[self.playIdx][2]
		else:
			url = self.session.nav.getCurrentlyPlayingServiceReference().getPath()

			if re.search('(putpat.tv|/myspass)', url, re.I):
				self.session.open(MessageBox, _("Fehler: URL ist nicht persistent !"), MessageBox.TYPE_INFO, timeout=5)
				return

		self.pl_entry[1] = url
		res = SimplePlaylistIO.addEntry(self.pl_name, self.pl_entry)
		if res == 1:
			self.session.open(MessageBox, _("Eintrag hinzugefügt"), MessageBox.TYPE_INFO, timeout=5)
		elif res == 0:
			self.session.open(MessageBox, _("Eintrag schon vorhanden"), MessageBox.TYPE_INFO, timeout=5)
		else:
			self.session.open(MessageBox, _("Fehler!"), MessageBox.TYPE_INFO, timeout=5)

	def showCover(self, cover):
		#print "showCover:", cover
		if config.supportchannel.sp_infobar_cover_off.value:
			self.hideSPCover()
			self["Cover"].hide()
			return
		if self.coverBGisHidden:
			self.showSPCover()
		self._Cover.getCover(cover)

	def showIcon(self):
		print "showIcon:"
		pm_file = self.wallicon_path + mp_globals.activeIcon + ".png"
		self._Icon.showCoverFile(pm_file)

	def hideSPCover(self):
		#print "hideSPCover:"
		if not self.coverBGisHidden:
			self['spcoverframe'].hide()
			self['spcoverfg'].hide()
			self.coverBGisHidden = True

	def showSPCover(self):
		print "showSPCover:"
		if self.coverBGisHidden:
			self['spcoverframe'].show()
			self['spcoverfg'].show()
			self.coverBGisHidden = False

	#def lockShow(self):
	#	pass

	#def unlockShow(self):
	#	pass

	def configSaver(self):
		print "configSaver:"
		self.scrSaver = config.supportchannel.sp_scrsaver.value
		print "Savermode: ",self.scrSaver
		if self.scrSaver == 'automatic' and self.autoScrSaver or self.scrSaver == 'on':
			if not self.saverActive:
				self.SaverTimer.start(1000*60, True)
				self.saverActive = True
				print "scrsaver timer startet"
		else:
			self.SaverTimer.stop()
			self.saverActive = False

	def openSaver(self):
		print "openSaver:"
		self.session.openWithCallback(self.cb_Saver, SimpleScreenSaver)

	def cb_Saver(self):
		print "cb_Saver:"
		self.saverActive = False
		self.configSaver()

	def createSummary(self):
		print "createSummary"
		return SimplePlayerSummary

	def setActionPrio(self):
		if config.supportchannel.sp_use_number_seek.value:
			self.action_prio = -2
		else:
			self.action_prio = -1

	def runPlugin(self, plugin):
		plugin(session=self.session)
示例#5
0
	def __init__(self, session, playList, playIdx, playMode, listTitle=None, plType='local', title_inr=0, queue=None, mp_event=None, listEntryPar=None, playFunc=None, playerMode=None):
		self.session = session

		self.plugin_path = mp_globals.pluginPath
		self.skin_path =  mp_globals.pluginPath + "/skins"

		path = "%s/%s/defaultPlaylistScreen.xml" % (self.skin_path, config.supportchannel.skin.value)
		if not fileExists(path):
			path = self.skin_path + "/original/defaultPlaylistScreen.xml"

		with open(path, "r") as f:
			self.skin = f.read()
			f.close()

		self["hidePig"] = Boolean()
		self["hidePig"].setBoolean(config.supportchannel.minitv.value)

		Screen.__init__(self, session)

		self["actions"] = ActionMap(["OkCancelActions",'MediaPlayerSeekActions',"EPGSelectActions",'ColorActions','InfobarActions'],
		{
			'cancel':	self.exit,
			'red':		self.exit,
			'green':	self.toPlayer,
			'yellow':	self.changePlaymode,
			'blue':		self.deleteEntry,
			'ok': 		self.ok
		}, -2)

		self.playList = playList
		self.playIdx = playIdx
		self.listTitle = listTitle
		self.plType = plType
		self.title_inr = title_inr
		self.playlistQ = queue
		self.event = mp_event
		self.listEntryPar = listEntryPar
		self.playMode = playMode
		self.playFunc = playFunc
		self.playerMode = playerMode

		self["title"] = Label("")
		self["coverArt"] = Pixmap()
		self._Cover = CoverHelper(self['coverArt'])
		self["songtitle"] = Label ("")
		self["artist"] = Label ("")
		self["album"] = Label ("")
		if self.plType == 'global':
			self['F4'] = Label("Löschen")
		else:
			self['F4'] = Label("")
		if playerMode in 'MP3':
			self['F2'] = Label("to Player")
		else:
			self['F2'] = Label("")
		self['F3'] = Label("Playmode")
		self['F1'] = Label("Exit")
		self['playmode'] = Label(self.playMode[0].capitalize())

		self.chooseMenuList = MenuList([], enableWrapAround=True, content=eListboxPythonMultiContent)
		self.chooseMenuList.l.setFont(0, gFont('mediaportal', 23))
		if self.plType != 'global' and self.listEntryPar:
			self.chooseMenuList.l.setItemHeight(self.listEntryPar[3])
		else:
			self.chooseMenuList.l.setItemHeight(25)
		self['streamlist'] = self.chooseMenuList

		self.onClose.append(self.resetEvent)

		self.onLayoutFinish.append(self.showPlaylist)
示例#6
0
class SimplePlaylist(Screen):

	def __init__(self, session, playList, playIdx, playMode, listTitle=None, plType='local', title_inr=0, queue=None, mp_event=None, listEntryPar=None, playFunc=None, playerMode=None):
		self.session = session

		self.plugin_path = mp_globals.pluginPath
		self.skin_path =  mp_globals.pluginPath + "/skins"

		path = "%s/%s/defaultPlaylistScreen.xml" % (self.skin_path, config.supportchannel.skin.value)
		if not fileExists(path):
			path = self.skin_path + "/original/defaultPlaylistScreen.xml"

		with open(path, "r") as f:
			self.skin = f.read()
			f.close()

		self["hidePig"] = Boolean()
		self["hidePig"].setBoolean(config.supportchannel.minitv.value)

		Screen.__init__(self, session)

		self["actions"] = ActionMap(["OkCancelActions",'MediaPlayerSeekActions',"EPGSelectActions",'ColorActions','InfobarActions'],
		{
			'cancel':	self.exit,
			'red':		self.exit,
			'green':	self.toPlayer,
			'yellow':	self.changePlaymode,
			'blue':		self.deleteEntry,
			'ok': 		self.ok
		}, -2)

		self.playList = playList
		self.playIdx = playIdx
		self.listTitle = listTitle
		self.plType = plType
		self.title_inr = title_inr
		self.playlistQ = queue
		self.event = mp_event
		self.listEntryPar = listEntryPar
		self.playMode = playMode
		self.playFunc = playFunc
		self.playerMode = playerMode

		self["title"] = Label("")
		self["coverArt"] = Pixmap()
		self._Cover = CoverHelper(self['coverArt'])
		self["songtitle"] = Label ("")
		self["artist"] = Label ("")
		self["album"] = Label ("")
		if self.plType == 'global':
			self['F4'] = Label("Löschen")
		else:
			self['F4'] = Label("")
		if playerMode in 'MP3':
			self['F2'] = Label("to Player")
		else:
			self['F2'] = Label("")
		self['F3'] = Label("Playmode")
		self['F1'] = Label("Exit")
		self['playmode'] = Label(self.playMode[0].capitalize())

		self.chooseMenuList = MenuList([], enableWrapAround=True, content=eListboxPythonMultiContent)
		self.chooseMenuList.l.setFont(0, gFont('mediaportal', 23))
		if self.plType != 'global' and self.listEntryPar:
			self.chooseMenuList.l.setItemHeight(self.listEntryPar[3])
		else:
			self.chooseMenuList.l.setItemHeight(25)
		self['streamlist'] = self.chooseMenuList

		self.onClose.append(self.resetEvent)

		self.onLayoutFinish.append(self.showPlaylist)

	def updateStatus(self):
		print "updateStatus:"
		if self.playlistQ and not self.playlistQ.empty():
			t = self.playlistQ.get_nowait()
			self["songtitle"].setText(t[1])
			self["artist"].setText(t[2])
			self["album"].setText(t[3])
			self.getCover(t[4])
			if t[5] == self.plType:
				self.playIdx = t[0]
				if self.playIdx >= len(self.playList):
					self.playIdx = 0
				self['streamlist'].moveToIndex(self.playIdx)

	def playListEntry(self, entry):
		if self.plType != 'global' and self.listEntryPar:
			return [entry,
				(eListboxPythonMultiContent.TYPE_TEXT, self.listEntryPar[0], self.listEntryPar[1], self.listEntryPar[2], self.listEntryPar[3], self.listEntryPar[4], RT_HALIGN_LEFT | RT_VALIGN_CENTER, entry[self.listEntryPar[6]]+self.listEntryPar[5]+entry[self.listEntryPar[7]])
				]
		else:
			return [entry,
				(eListboxPythonMultiContent.TYPE_TEXT, 20, 0, 860, 25, 0, RT_HALIGN_LEFT | RT_VALIGN_CENTER, entry[self.title_inr])
				]

	def showPlaylist(self):
		print 'showPlaylist:'

		if self.listTitle:
			self['title'].setText("MP Playlist - %s" % self.listTitle)
		else:
			self['title'].setText("MP %s Playlist-%02d" % (self.plType, config.supportchannel.sp_pl_number.value))

		self.chooseMenuList.setList(map(self.playListEntry, self.playList))

		if self.event:
			self.event.addCallback(self.updateStatus)
		else:
			self['streamlist'].moveToIndex(self.playIdx)

	def getCover(self, url):
		print "getCover:", url
		self._Cover.getCover(url)

	def deleteEntry(self):
		if self.plType == 'global':
			idx = self['streamlist'].getSelectedIndex()
			self.close([idx,'del',self.playList])

	def toPlayer(self):
		if self.playerMode in 'MP3':
			self.close([-2,'',self.playList])

	def exit(self):
		self.close([-1,'',self.playList])

	def ok(self):
		if len(self.playList) == 0:
			self.exit()
		idx = self['streamlist'].getSelectedIndex()
		if self.playFunc:
			self.playFunc(idx)
		else:
			self.close([idx,'',self.playList])

	def resetEvent(self):
		print "resetEvent:"
		if self.event:
			self.event.reset()

	def createSummary(self):
		print "createSummary"
		return SimplePlayerSummary

	def changePlaymode(self):
		if self.playMode[0] == "forward":
			self.playMode[0] = "backward"
		elif self.playMode[0] == "backward":
			self.playMode[0] = "random"
		else:
			self.playMode[0] = "forward"

		self["playmode"].setText(self.playMode[0].capitalize())
示例#7
0
	def __init__(self, session, playList, playIdx, listTitle=None, plType='local', title_inr=0, queue=None, mp_event=None, listEntryPar=None):
		self.session = session

		self.plugin_path = mp_globals.pluginPath
		self.skin_path =  mp_globals.pluginPath + "/skins"

		path = "%s/%s/defaultPlaylistScreen.xml" % (self.skin_path, config.mediaportal.skin.value)
		if not fileExists(path):
			path = self.skin_path + "/original/defaultPlaylistScreen.xml"

		with open(path, "r") as f:
			self.skin = f.read()
			f.close()

		Screen.__init__(self, session)

		self["actions"] = ActionMap(["OkCancelActions",'MediaPlayerSeekActions',"EPGSelectActions",'ColorActions','InfobarActions'],
		{
			'cancel':	self.exit,
			'red':		self.exit,
			'blue':		self.deleteEntry,
			'ok': 		self.ok
		}, -2)

		self.playList = playList
		self.playIdx = playIdx
		self.listTitle = listTitle
		self.plType = plType
		self.title_inr = title_inr
		self.playlistQ = queue
		self.event = mp_event
		self.listEntryPar = listEntryPar

		self["title"] = Label("")
		self["coverArt"] = Pixmap()
		self._Cover = CoverHelper(self['coverArt'])
		self["songtitle"] = Label ("")
		self["artist"] = Label ("")
		self["album"] = Label ("")
		if self.plType == 'global':
			self['F4'] = Label("Löschen")
		else:
			self['F4'] = Label("")
		self['F2'] = Label("")
		self['F3'] = Label("")
		self['F1'] = Label("Exit")

		#self.updateTimer = eTimer()
		#self.updateTimer.callback.append(self.updateStatus)

		self.chooseMenuList = MenuList([], enableWrapAround=True, content=eListboxPythonMultiContent)
		self.chooseMenuList.l.setFont(0, gFont('mediaportal', 23))
		if self.plType != 'global' and self.listEntryPar:
			self.chooseMenuList.l.setItemHeight(self.listEntryPar[3])
		else:
			self.chooseMenuList.l.setItemHeight(25)
		self['streamlist'] = self.chooseMenuList

		self.onClose.append(self.resetEvent)

		self.onLayoutFinish.append(self.showPlaylist)
示例#8
0
class SimplePlaylist(Screen):

	def __init__(self, session, playList, playIdx, listTitle=None, plType='local', title_inr=0, queue=None, mp_event=None, listEntryPar=None):
		self.session = session

		self.plugin_path = mp_globals.pluginPath
		self.skin_path =  mp_globals.pluginPath + "/skins"

		path = "%s/%s/defaultPlaylistScreen.xml" % (self.skin_path, config.mediaportal.skin.value)
		if not fileExists(path):
			path = self.skin_path + "/original/defaultPlaylistScreen.xml"

		with open(path, "r") as f:
			self.skin = f.read()
			f.close()

		Screen.__init__(self, session)

		self["actions"] = ActionMap(["OkCancelActions",'MediaPlayerSeekActions',"EPGSelectActions",'ColorActions','InfobarActions'],
		{
			'cancel':	self.exit,
			'red':		self.exit,
			'blue':		self.deleteEntry,
			'ok': 		self.ok
		}, -2)

		self.playList = playList
		self.playIdx = playIdx
		self.listTitle = listTitle
		self.plType = plType
		self.title_inr = title_inr
		self.playlistQ = queue
		self.event = mp_event
		self.listEntryPar = listEntryPar

		self["title"] = Label("")
		self["coverArt"] = Pixmap()
		self._Cover = CoverHelper(self['coverArt'])
		self["songtitle"] = Label ("")
		self["artist"] = Label ("")
		self["album"] = Label ("")
		if self.plType == 'global':
			self['F4'] = Label("Löschen")
		else:
			self['F4'] = Label("")
		self['F2'] = Label("")
		self['F3'] = Label("")
		self['F1'] = Label("Exit")

		#self.updateTimer = eTimer()
		#self.updateTimer.callback.append(self.updateStatus)

		self.chooseMenuList = MenuList([], enableWrapAround=True, content=eListboxPythonMultiContent)
		self.chooseMenuList.l.setFont(0, gFont('mediaportal', 23))
		if self.plType != 'global' and self.listEntryPar:
			self.chooseMenuList.l.setItemHeight(self.listEntryPar[3])
		else:
			self.chooseMenuList.l.setItemHeight(25)
		self['streamlist'] = self.chooseMenuList

		self.onClose.append(self.resetEvent)

		self.onLayoutFinish.append(self.showPlaylist)

	def updateStatus(self):
		print "updateStatus:"
		if self.playlistQ and not self.playlistQ.empty():
			t = self.playlistQ.get_nowait()
			self["songtitle"].setText(t[1])
			self["artist"].setText(t[2])
			self["album"].setText(t[3])
			self.getCover(t[4])
			if t[5] == self.plType:
				self.playIdx = t[0]
				if self.playIdx >= len(self.playList):
					self.playIdx = 0
				self['streamlist'].moveToIndex(self.playIdx)

		#self.updateTimer.start(1000, True)

	def playListEntry(self, entry):
		if self.plType != 'global' and self.listEntryPar:
			return [entry,
				(eListboxPythonMultiContent.TYPE_TEXT, self.listEntryPar[0], self.listEntryPar[1], self.listEntryPar[2], self.listEntryPar[3], self.listEntryPar[4], RT_HALIGN_LEFT | RT_VALIGN_CENTER, entry[self.listEntryPar[6]]+self.listEntryPar[5]+entry[self.listEntryPar[7]])
				]
		else:
			return [entry,
				(eListboxPythonMultiContent.TYPE_TEXT, 20, 0, 860, 25, 0, RT_HALIGN_LEFT | RT_VALIGN_CENTER, entry[self.title_inr])
				]

	def showPlaylist(self):
		print 'showPlaylist:'

		if self.listTitle:
			self['title'].setText("MP Playlist - %s" % self.listTitle)
		else:
			self['title'].setText("MP %s Playlist-%02d" % (self.plType, config.mediaportal.sp_pl_number.value))

		self.chooseMenuList.setList(map(self.playListEntry, self.playList))

		if self.event:
			self.event.addCallback(self.updateStatus)
		else:
			self['streamlist'].moveToIndex(self.playIdx)
		#self.updateTimer.start(100, True)


	def getCover(self, url):
		print "getCover:", url
		self._Cover.getCover(url)

	def deleteEntry(self):
		if self.plType == 'global':
			idx = self['streamlist'].getSelectedIndex()
			self.close([idx,'del',self.playList])

	def exit(self):
		self.close([-1,'',self.playList])

	def ok(self):
		if len(self.playList) == 0:
			self.exit()
		idx = self['streamlist'].getSelectedIndex()
		self.close([idx,'',self.playList])

	def resetEvent(self):
		print "resetEvent:"
		if self.event:
			self.event.reset()

	def createSummary(self):
		print "createSummary"
		return SimplePlayerSummary
示例#9
0
    def __init__(
        self,
        session,
        playList,
        playIdx=0,
        playAll=False,
        listTitle=None,
        plType="local",
        title_inr=0,
        cover=False,
        ltype="",
        autoScrSaver=False,
        showPlaylist=True,
    ):

        Screen.__init__(self, session)
        print "SimplePlayer:"
        self.session = session
        self.plugin_path = mp_globals.pluginPath
        self.skin_path = mp_globals.pluginPath + "/skins"
        self.wallicon_path = mp_globals.pluginPath + "/icons_wall/"

        path = "%s/tec/SimplePlayer.xml" % self.skin_path
        with open(path, "r") as f:
            self.skin = f.read()
            f.close()

        self["actions"] = ActionMap(
            [
                "WizardActions",
                "MediaPlayerSeekActions",
                "EPGSelectActions",
                "MoviePlayerActions",
                "ColorActions",
                "InfobarActions",
            ],
            {
                "leavePlayer": self.leavePlayer,
                "info": self.openMediainfo,
                "input_date_time": self.openMenu,
                "up": self.openPlaylist,
                "down": self.randomNow,
                "back": self.leavePlayer,
                "left": self.seekBack,
                "right": self.seekFwd,
            },
            -1,
        )

        SimpleSeekHelper.__init__(self)
        InfoBarNotifications.__init__(self)
        # InfoBarServiceNotifications.__init__(self)
        InfoBarBase.__init__(self)
        InfoBarShowHide.__init__(self)
        InfoBarAudioSelection.__init__(self)
        InfoBarSubtitleSupport.__init__(self)

        self.allowPiP = False
        InfoBarSeek.__init__(self)

        self.skinName = "MediaPortal SimplePlayer"
        self.lastservice = self.session.nav.getCurrentlyPlayingServiceReference()

        self.showPlaylist = showPlaylist
        self.scrSaver = ""
        self.saverActive = False
        self.autoScrSaver = autoScrSaver
        self.pl_open = False
        self.randomPlay = False
        self.playMode = ""
        self.listTitle = listTitle
        self.playAll = playAll
        self.playList = playList
        self.playIdx = playIdx
        self.playLen = len(playList)
        self.returning = False
        self.pl_entry = ["", "", "", "", "", "", "", "", ""]
        self.plType = plType
        self.playList2 = []
        self.pl_name = "mp_global_pl_01"
        self.title_inr = title_inr
        self.cover = cover
        self.ltype = ltype
        self.playlistQ = Queue.Queue(0)
        self.pl_status = (0, "", "", "", "")
        self.pl_event = SimpleEvent()
        self["spcoverframe"] = Pixmap()
        self["spcoverfg"] = Pixmap()
        self["Icon"] = Pixmap()
        self._Icon = CoverHelper(self["Icon"])

        # load default cover
        self["Cover"] = Pixmap()
        self._Cover = CoverHelper(self["Cover"], nc_callback=self.hideSPCover)
        self.cover_is_hidden = False

        self.SaverTimer = eTimer()
        self.SaverTimer.callback.append(self.openSaver)

        self.setPlaymode()
        self.configSaver()
        self.onClose.append(self.playExit)
        self.onFirstExecBegin.append(self.showIcon)
        self.onLayoutFinish.append(self.getVideo)
示例#10
0
class SimplePlayer(Screen, SimpleSeekHelper, InfoBarMenu, InfoBarBase, InfoBarSeek, InfoBarNotifications, InfoBarServiceNotifications, InfoBarPVRState, InfoBarShowHide, InfoBarAudioSelection, InfoBarSubtitleSupport, InfoBarSimpleEventView):
	ENABLE_RESUME_SUPPORT = True
	ALLOW_SUSPEND = True

	def __init__(self, session, playList, playIdx=0, playAll=False, listTitle=None, plType='local', title_inr=0, cover=False, ltype='', autoScrSaver=False, showPlaylist=True, listEntryPar=None, playList2=[]):
		try:
			from enigma import eServiceMP3
		except:
			is_eServiceMP3 = False
			print "No MP3 service"
		else:
			is_eServiceMP3 = True
			print "MP3 service imported"

		Screen.__init__(self, session)
		print "SimplePlayer:"
		self.session = session
		self.plugin_path = mp_globals.pluginPath
		self.skin_path = mp_globals.pluginPath + "/skins"
		self.wallicon_path = mp_globals.pluginPath + "/icons_wall/"

		path = "%s/simpleplayer/SimplePlayer.xml" % self.skin_path
		with open(path, "r") as f:
			self.skin = f.read()
			f.close()

		self.setActionPrio()
		self["actions"] = ActionMap(["WizardActions",'MediaPlayerSeekActions',"EPGSelectActions",'MoviePlayerActions','ColorActions','InfobarActions',"MenuActions","HelpActions"],
		{
			"leavePlayer": self.leavePlayer,
			config.mediaportal.sp_mi_key.value: self.openMediainfo,
			"menu":		self.openMenu,
			"up": 		self.openPlaylist,
			"down":		self.randomNow,
			"back":		self.leavePlayer,
			"left":		self.seekBack,
			"right":	self.seekFwd,
			"seekdef:1": self.Key1,
			"seekdef:3": self.Key3,
			"seekdef:4": self.Key4,
			"seekdef:6": self.Key6,
			"seekdef:7": self.Key7,
			"seekdef:9": self.Key9

		}, self.action_prio)

		SimpleSeekHelper.__init__(self)
		InfoBarMenu.__init__(self)
		InfoBarNotifications.__init__(self)
		InfoBarServiceNotifications.__init__(self)
		InfoBarBase.__init__(self)
		InfoBarShowHide.__init__(self)
		InfoBarAudioSelection.__init__(self)
		InfoBarSubtitleSupport.__init__(self)
		InfoBarSimpleEventView.__init__(self)

		self.allowPiP = False
		InfoBarSeek.__init__(self)
		InfoBarPVRState.__init__(self)

		self.skinName = 'MediaPortal SimplePlayer'
		self.lastservice = self.session.nav.getCurrentlyPlayingServiceReference()

		self.isTSVideo = False
		self.showGlobalPlaylist = True
		self.showPlaylist = showPlaylist
		self.scrSaver = ''
		self.saverActive = False
		self.autoScrSaver = autoScrSaver
		self.pl_open = False
		self.randomPlay = False
		self.playMode = ""
		self.listTitle = listTitle
		self.playAll = playAll
		self.playList = playList
		self.playIdx = playIdx
		if plType == 'local':
			self.playLen = len(playList)
		else:
			self.playLen = len(playList2)

		self.listEntryPar=listEntryPar
		self.returning = False
		self.pl_entry = ['', '', '', '', '', '', '', '', '']
		self.plType = plType
		self.playList2 = playList2
		self.pl_name = 'mp_global_pl_%02d' % config.mediaportal.sp_pl_number.value
		self.title_inr = title_inr
		self.cover = cover
		self.ltype = ltype
		self.playlistQ = Queue.Queue(0)
		self.pl_status = (0, '', '', '', '', '')
		self.pl_event = SimpleEvent()
		self['spcoverframe'] = Pixmap()
		self['spcoverfg'] = Pixmap()
		self['Icon'] = Pixmap()
		self._Icon = CoverHelper(self['Icon'])
		self['premiumizemeoff'] = Pixmap()
		self['premiumizemeon'] = Pixmap()
		self['premiumizemeon'].hide()

		# load default cover
		self['Cover'] = Pixmap()
		self._Cover = CoverHelper(self['Cover'], nc_callback=self.hideSPCover)
		self.coverBGisHidden = False
		self.cover2 = False

		self.SaverTimer = eTimer()
		self.SaverTimer.callback.append(self.openSaver)

		self.hideSPCover()
		self.setPlaymode()
		self.configSaver()
		self.onClose.append(self.playExit)
		self.onFirstExecBegin.append(self.showIcon)
		self.onFirstExecBegin.append(self.playVideo)

		if is_eServiceMP3:
			self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
				{
					eServiceMP3.evAudioDecodeError: self.__evAudioDecodeError,
					eServiceMP3.evVideoDecodeError: self.__evVideoDecodeError,
					eServiceMP3.evPluginError: self.__evPluginError,
					eServiceMP3.evStreamingSrcError: self.__evStreamingSrcError
				})

	def __evAudioDecodeError(self):
		if not config.mediaportal.sp_show_errors.value:
			return
		from Screens.MessageBox import MessageBox
		from enigma import iServiceInformation
		currPlay = self.session.nav.getCurrentService()
		sTagAudioCodec = currPlay.info().getInfoString(iServiceInformation.sTagAudioCodec)
		print "[__evAudioDecodeError] audio-codec %s can't be decoded by hardware" % (sTagAudioCodec)
		self.session.open(MessageBox, _("This STB can't decode %s streams!") % sTagAudioCodec, type = MessageBox.TYPE_INFO,timeout = 10 )

	def __evVideoDecodeError(self):
		if not config.mediaportal.sp_show_errors.value:
			return
		from Screens.MessageBox import MessageBox
		from enigma import iServiceInformation
		currPlay = self.session.nav.getCurrentService()
		sTagVideoCodec = currPlay.info().getInfoString(iServiceInformation.sTagVideoCodec)
		print "[__evVideoDecodeError] video-codec %s can't be decoded by hardware" % (sTagVideoCodec)
		self.session.open(MessageBox, _("This STB can't decode %s streams!") % sTagVideoCodec, type = MessageBox.TYPE_INFO,timeout = 10 )

	def __evPluginError(self):
		if not config.mediaportal.sp_show_errors.value:
			return
		from Screens.MessageBox import MessageBox
		from enigma import iServiceInformation
		currPlay = self.session.nav.getCurrentService()
		message = currPlay.info().getInfoString(iServiceInformation.sUser+12)
		print "[__evPluginError]" , message
		self.session.open(MessageBox, message, type = MessageBox.TYPE_INFO,timeout = 10 )

	def __evStreamingSrcError(self):
		if not config.mediaportal.sp_show_errors.value:
			return
		from Screens.MessageBox import MessageBox
		from enigma import iServiceInformation
		currPlay = self.session.nav.getCurrentService()
		message = currPlay.info().getInfoString(iServiceInformation.sUser+12)
		print "[__evStreamingSrcError]", message
		self.session.open(MessageBox, _("Streaming error: %s") % message, type = MessageBox.TYPE_INFO,timeout = 10 )

	def playVideo(self):
		print "playVideo:"
		self.isTSVideo = False
		if self.seekBarLocked:
			self.cancelSeek()
		self.resetMySpass()
		if self.plType == 'global':
			self.getVideo2()
		else:
			self.cover2 = False
			self.getVideo()

	def dataError(self, error):
		print "dataError:"
		if config.mediaportal.sp_show_errors.value:
			self.session.openWithCallback(self.dataError2, MessageBox, str(error), MessageBox.TYPE_INFO, timeout=10)
		printl(error,self,"E")

	def dataError2(self, res):
		self.playNextStream(config.mediaportal.sp_on_movie_eof.value)

	def playStream(self, title, url=None, album='', artist='', imgurl=''):
		print "playStream: ",title,url
		if not url:
			return
			
		if mp_globals.proxy:
			self['premiumizemeoff'].hide()
			self['premiumizemeon'].show()
			mp_globals.proxy = False
		else:
			self['premiumizemeon'].hide()
			self['premiumizemeoff'].show()

		if self.cover or self.cover2:
			self.showCover(imgurl)

		if url.endswith('.ts'):
			sref = eServiceReference(0x0001, 0, url)
			self.isTSVideo = True
		else:
			sref = eServiceReference(0x1001, 0, url)
			self.isTSVideo = False

		pos = title.find('. ', 0, 5)
		if pos > 0:
			pos += 2
			title = title[pos:]

		if artist != '':
			sref.setName(artist + ' - ' + title)
		else:
			sref.setName(title)

		if self.cover:
			cflag = '1'
		else:
			cflag = '0'

		self.pl_entry = [title, None, artist, album, self.ltype, '', imgurl, cflag]
		self.session.nav.stopService()
		self.session.nav.playService(sref)

		self.pl_status = (self.playIdx, title, artist, album, imgurl, self.plType)
		if self.pl_open:
			self.playlistQ.put(self.pl_status)
			self.pl_event.genEvent()

	def playPrevStream(self):
		print "_prevStream:"
		if not self.playAll or self.playLen <= 1:
			self.handleLeave(config.mediaportal.sp_on_movie_stop.value)
		else:
			if self.playIdx > 0:
				self.playIdx -= 1
			else:
				self.playIdx = self.playLen - 1
			self.playVideo()

	def playNextStream(self, value):
		print "playNextStream:"
		if not self.playAll or self.playLen <= 1:
			self.handleLeave(value)
		else:
			if self.playIdx in range(0, self.playLen-1):
				self.playIdx += 1
			else:
				self.playIdx = 0
			self.playVideo()

	def playRandom(self, value):
		print 'playRandom:'
		if self.playLen > 1 and self.playAll:
			self.playIdx = random.randint(0, self.playLen-1)
			self.playVideo()
		else:
			self.handleLeave(value)

	def randomNow(self):
		if self.playAll:
			self.playRandom(config.mediaportal.sp_on_movie_stop.value)

	def seekFwd(self):
		if self.isTSVideo:
			InfoBarSeek.seekFwd(self)
		elif self.seekBarShown and not self.seekBarLocked:
			self.initSeek()
		elif self.seekBarLocked:
			self.seekRight()
		elif self.playAll:
			self.playNextStream(config.mediaportal.sp_on_movie_stop.value)

	def seekBack(self):
		if self.isTSVideo:
			InfoBarSeek.seekBack(self)
		elif self.seekBarShown and not self.seekBarLocked:
			self.initSeek()
		elif self.seekBarLocked:
			self.seekLeft()
		elif self.playAll:
			self.playPrevStream()

	def Key1(self):
		self.isNumberSeek = True
		self.initSeek()
		self.numberKeySeek(-int(config.seek.selfdefined_13.value))

	def Key3(self):
		self.isNumberSeek = True
		self.initSeek()
		self.numberKeySeek(int(config.seek.selfdefined_13.value))

	def Key4(self):
		self.isNumberSeek = True
		self.initSeek()
		self.numberKeySeek(-int(config.seek.selfdefined_46.value))

	def Key6(self):
		self.isNumberSeek = True
		self.initSeek()
		self.numberKeySeek(int(config.seek.selfdefined_46.value))

	def Key7(self):
		self.isNumberSeek = True
		self.initSeek()
		self.numberKeySeek(-int(config.seek.selfdefined_79.value))

	def Key9(self):
		self.isNumberSeek = True
		self.initSeek()
		self.numberKeySeek(int(config.seek.selfdefined_79.value))

	def handleLeave(self, how):
		print "handleLeave:"
		self.is_closing = True
		if how == "ask":
			if self.plType == 'local':
				list = (
					(_("Ja"), "quit"),
					("Ja & Service zur glob. Playlist-%02d hinzufügen" % config.mediaportal.sp_pl_number.value, "add"),
					(_("Nein"), "continue"),
					(_("Nein, aber von Anfang an neu beginnen"), "restart")
				)
			else:
				list = (
					(_("Ja"), "quit"),
					(_("Nein"), "continue"),
					(_("Nein, aber von Anfang an neu beginnen"), "restart")
				)

			from Screens.ChoiceBox import ChoiceBox
			self.session.openWithCallback(self.leavePlayerConfirmed, ChoiceBox, title=_("Stop playing this movie?"), list = list)
		else:
			self.leavePlayerConfirmed([True, how])

	def leavePlayerConfirmed(self, answer):
		print "leavePlayerConfirmed:"
		answer = answer and answer[1]
		print answer

		if answer in ("quit", "movielist"):
			self.close()
		elif answer == "restart":
			if self.isMySpass:
				self.restartMySpass()
			else:
				self.doSeek(0)
				self.setSeekState(self.SEEK_STATE_PLAY)
		elif answer == "add":
			self.addToPlaylist()
			self.close()

	def leavePlayer(self):
		print "leavePlayer:"
		if self.seekBarLocked:
			self.cancelSeek()
		else:
			self.handleLeave(config.mediaportal.sp_on_movie_stop.value)

	def doEofInternal(self, playing):
		print "doEofInt:"
		if playing:
			if self.randomPlay:
				self.playRandom(config.mediaportal.sp_on_movie_eof.value)
			else:
				self.playNextStream(config.mediaportal.sp_on_movie_eof.value)

	def playExit(self):
		print "playExit:"
		self.SaverTimer.stop()
		if config.mediaportal.restorelastservice.value == "1":
			self.session.nav.playService(self.lastservice)
		else:
			self.session.nav.stopService()

	def getVideo(self):
		print "getVideo:"
		title = self.playList[self.playIdx][0]
		url = self.playList[self.playIdx][1]
		if len(self.playList[0]) == 3:
			iurl = self.playList[self.playIdx][2]
		else:
			iurl = ''
		self.playStream(title, url, imgurl=iurl)

	def getVideo2(self):
		print "getVideo2:"
		if self.playLen > 0:
			titel = self.playList2[self.playIdx][1]
			url = self.playList2[self.playIdx][2]
			album = self.playList2[self.playIdx][3]
			artist = self.playList2[self.playIdx][4]
			imgurl = self.playList2[self.playIdx][7]
			self.cover2 = self.playList2[self.playIdx][8] == '1' and self.plType == 'global'

			if len(self.playList2[self.playIdx]) < 6:
				ltype = ''
			else:
				ltype = self.playList2[self.playIdx][5]

			if ltype == 'youtube':
				YoutubeLink(self.session).getLink(self.playStream, self.dataError, titel, url, imgurl)
			elif ltype == 'putpattv':
				token = self.playList2[self.playIdx][6]
				PutpattvLink(self.session).getLink(self.playStream, self.dataError, titel, url, token, imgurl)
			elif ltype == 'myvideo':
				token = self.playList2[self.playIdx][6]
				MyvideoLink(self.session).getLink(self.playStream, self.dataError, titel, url, token, imgurl)
			elif ltype == 'songsto' and not url:
				token = self.playList2[self.playIdx][6]
				SongstoLink(self.session).getLink(self.playStream, self.dataError, titel, artist, album, token, imgurl)
			elif ltype == 'canna':
				CannaLink(self.session).getLink(self.playStream, self.dataError, titel, artist, album, url, imgurl)
			elif ltype == 'eighties':
				token = self.playList2[self.playIdx][6]
				EightiesLink(self.session).getLink(self.playStream, self.dataError, titel, artist, album, url, token, imgurl)
			elif ltype == 'mtv':
				MTVdeLink(self.session).getLink(self.playStream, self.dataError, titel, artist, url, imgurl)
			elif url:
				self.playStream(titel, url, album, artist, imgurl=imgurl)
		else:
			self.close()

	def openPlaylist(self):
		if  ((self.showGlobalPlaylist and self.plType == 'global') or self.showPlaylist) and self.playLen > 0:
			if self.playlistQ.empty():
				self.playlistQ.put(self.pl_status)
			self.pl_open = True
			self.pl_event.genEvent()

			if self.plType == 'local':
				self.session.openWithCallback(self.cb_Playlist, SimplePlaylist, self.playList, self.playIdx, listTitle=self.listTitle, plType=self.plType, title_inr=self.title_inr, queue=self.playlistQ, mp_event=self.pl_event, listEntryPar=self.listEntryPar)
			else:
				self.session.openWithCallback(self.cb_Playlist, SimplePlaylist, self.playList2, self.playIdx, listTitle=None, plType=self.plType, title_inr=0, queue=self.playlistQ, mp_event=self.pl_event, listEntryPar=self.listEntryPar)
		elif not self.playLen:
			self.session.open(MessageBox, _("Keine Einträge in der Playlist vorhanden!"), MessageBox.TYPE_INFO, timeout=5)

	def cb_Playlist(self, data):
		self.pl_open = False

		while not self.playlistQ.empty():
			t = self.playlistQ.get_nowait()

		if data[0] != -1:
			self.playIdx = data[0]
			if self.plType == 'global':
				if data[1] == 'del':
					self.session.nav.stopService()
					SimplePlaylistIO.delEntry(self.pl_name, self.playList2, self.playIdx)
					self.playLen = len(self.playList2)
					if self.playIdx >= self.playLen:
						self.playIdx -= 1
					if self.playIdx < 0:
						self.close()
					else:
						self.openPlaylist()
			self.playVideo()

	def openMediainfo(self):
		if MediainfoPresent:
			url = self.session.nav.getCurrentlyPlayingServiceReference().getPath()
			if url[:4] == "http":
				self.session.open(mediaInfo, True)

	def openMenu(self):
		self.session.openWithCallback(self.cb_Menu, SimplePlayerMenu, self.plType, self.showPlaylist or self.showGlobalPlaylist)

	def cb_Menu(self, data):
		print "cb_Menu:"
		if data != []:
			if data[0] == 1:
				self.setPlaymode()
				self.configSaver()
				if self.cover or self.cover2:
					self.showCover(self.pl_entry[6])
				self.pl_name = 'mp_global_pl_%02d' % config.mediaportal.sp_pl_number.value
			elif data[0] == 2:
				self.addToPlaylist()

			elif data[0] == 3:
				nm = self.pl_name
				pl_list = SimplePlaylistIO.getPL(nm)
				self.playList2 = pl_list
				playLen = len(self.playList2)
				if playLen > 0:
					self.playIdx = 0
					self.playLen = playLen
					self.plType = 'global'
				self.openPlaylist()

			elif data[0] == 4:
				if self.plType != 'local':
					playLen = len(self.playList)
					if playLen > 0:
						self.playIdx = 0
						self.playLen = playLen
						self.plType = 'local'
						self.playList2 = []
					self.openPlaylist()

			elif data[0] == 6:
				self.mainMenu()

	def addToPlaylist(self):
		if self.plType != 'local':
			self.session.open(MessageBox, _("Fehler: Service darf nur von der lok. PL hinzugefügt werden"), MessageBox.TYPE_INFO, timeout=5)
			return

		if self.pl_entry[4] == 'youtube':
			url = self.playList[self.playIdx][2]
		elif self.pl_entry[4] == 'myvideo':
			url = self.playList[self.playIdx][1]
			self.pl_entry[5] = self.playList[self.playIdx][2]
		elif self.pl_entry[4] == 'mtv':
			url = self.playList[self.playIdx][1]
		elif self.pl_entry[4] == 'putpattv' and self.playList[self.playIdx][2]:
			url = self.playList[self.playIdx][1]
			self.pl_entry[5] = self.playList[self.playIdx][2]
		else:
			url = self.session.nav.getCurrentlyPlayingServiceReference().getPath()

			if re.search('(putpat.tv|/myspass)', url, re.I):
				self.session.open(MessageBox, _("Fehler: URL ist nicht persistent !"), MessageBox.TYPE_INFO, timeout=5)
				return

		self.pl_entry[1] = url
		res = SimplePlaylistIO.addEntry(self.pl_name, self.pl_entry)
		if res == 1:
			self.session.open(MessageBox, _("Eintrag hinzugefügt"), MessageBox.TYPE_INFO, timeout=5)
		elif res == 0:
			self.session.open(MessageBox, _("Eintrag schon vorhanden"), MessageBox.TYPE_INFO, timeout=5)
		else:
			self.session.open(MessageBox, _("Fehler!"), MessageBox.TYPE_INFO, timeout=5)

	def showCover(self, cover):
		#print "showCover:", cover
		if config.mediaportal.sp_infobar_cover_off.value:
			self.hideSPCover()
			self["Cover"].hide()
			return
		if self.coverBGisHidden:
			self.showSPCover()
		self._Cover.getCover(cover)

	def showIcon(self):
		print "showIcon:"
		pm_file = self.wallicon_path + mp_globals.activeIcon + ".png"
		self._Icon.showCoverFile(pm_file)

	def hideSPCover(self):
		#print "hideSPCover:"
		if not self.coverBGisHidden:
			self['spcoverframe'].hide()
			self['spcoverfg'].hide()
			self.coverBGisHidden = True

	def showSPCover(self):
		print "showSPCover:"
		if self.coverBGisHidden:
			self['spcoverframe'].show()
			self['spcoverfg'].show()
			self.coverBGisHidden = False

	#def lockShow(self):
	#	pass

	#def unlockShow(self):
	#	pass

	def configSaver(self):
		print "configSaver:"
		self.scrSaver = config.mediaportal.sp_scrsaver.value
		print "Savermode: ",self.scrSaver
		if self.scrSaver == 'automatic' and self.autoScrSaver or self.scrSaver == 'on':
			if not self.saverActive:
				self.SaverTimer.start(1000*60, True)
				self.saverActive = True
				print "scrsaver timer startet"
		else:
			self.SaverTimer.stop()
			self.saverActive = False

	def openSaver(self):
		print "openSaver:"
		self.session.openWithCallback(self.cb_Saver, SimpleScreenSaver)

	def cb_Saver(self):
		print "cb_Saver:"
		self.saverActive = False
		self.configSaver()

	def setPlaymode(self):
		print "setPlaymode:"
		self.randomPlay = config.mediaportal.sp_randomplay.value
		if self.randomPlay:
			self.playMode = "Random"
		else:
			self.playMode = "Next"

	def createSummary(self):
		print "createSummary"
		return SimplePlayerSummary

	def setActionPrio(self):
		if config.mediaportal.sp_use_number_seek.value:
			self.action_prio = -2
		else:
			self.action_prio = -1
示例#11
0
 def loadDefaultCover(self):
     CoverHelper(self['coverArt']).getCover(self.default_cover)
示例#12
0
 def updateCover(self, filename):
     CoverHelper(self['cover']).getCover(filename)
示例#13
0
class SimplePlaylist(Screen):
    def __init__(
        self, session, playList, playIdx, listTitle=None, plType="local", title_inr=0, queue=None, mp_event=None
    ):
        self.session = session

        self.plugin_path = mp_globals.pluginPath
        self.skin_path = mp_globals.pluginPath + "/skins"

        path = "%s/%s/showSongstoAll.xml" % (self.skin_path, config.mediaportal.skin.value)
        if not fileExists(path):
            path = self.skin_path + "/original/showSongstoAll.xml"

        with open(path, "r") as f:
            self.skin = f.read()
            f.close()

        Screen.__init__(self, session)

        self["actions"] = ActionMap(
            ["OkCancelActions", "MediaPlayerSeekActions", "EPGSelectActions", "ColorActions", "InfobarActions"],
            {"cancel": self.exit, "red": self.red, "ok": self.ok},
            -2,
        )

        self.playList = playList
        self.playIdx = playIdx
        self.listTitle = listTitle
        self.plType = plType
        self.title_inr = title_inr
        self.playlistQ = queue
        self.event = mp_event

        self["title"] = Label("")
        self["coverArt"] = Pixmap()
        self._Cover = CoverHelper(self["coverArt"])
        self["songtitle"] = Label("")
        self["artist"] = Label("")
        self["album"] = Label("")
        if self.plType == "global":
            self["F1"] = Label("Löschen")
        else:
            self["F1"] = Label("")
        self["F2"] = Label("")
        self["F3"] = Label("")
        self["F4"] = Label("")

        # self.updateTimer = eTimer()
        # self.updateTimer.callback.append(self.updateStatus)

        self.chooseMenuList = MenuList([], enableWrapAround=True, content=eListboxPythonMultiContent)
        self.chooseMenuList.l.setFont(0, gFont("mediaportal", 23))
        self.chooseMenuList.l.setItemHeight(25)
        self["streamlist"] = self.chooseMenuList

        self.onClose.append(self.resetEvent)

        self.onLayoutFinish.append(self.showPlaylist)

    def updateStatus(self):
        print "updateStatus:"
        if self.playlistQ and not self.playlistQ.empty():
            t = self.playlistQ.get_nowait()
            self["songtitle"].setText(t[1])
            self["artist"].setText(t[2])
            self["album"].setText(t[3])
            self.getCover(t[4])
            if t[5] == self.plType:
                self.playIdx = t[0]
                if self.playIdx >= len(self.playList):
                    self.playIdx = 0
                self["streamlist"].moveToIndex(self.playIdx)

                # self.updateTimer.start(1000, True)

    def playListEntry(self, entry):
        return [
            entry,
            (
                eListboxPythonMultiContent.TYPE_TEXT,
                20,
                0,
                860,
                25,
                0,
                RT_HALIGN_LEFT | RT_VALIGN_CENTER,
                entry[self.title_inr],
            ),
        ]

    def showPlaylist(self):
        print "showPlaylist:"

        if self.listTitle:
            self["title"].setText("MP Playlist - %s" % self.listTitle)
        else:
            self["title"].setText("MP %s Playlist" % self.plType)

        self.chooseMenuList.setList(map(self.playListEntry, self.playList))

        if self.event:
            self.event.addCallback(self.updateStatus)
        else:
            self["streamlist"].moveToIndex(self.playIdx)
            # self.updateTimer.start(100, True)

    def getCover(self, url):
        print "getCover:", url
        self._Cover.getCover(url)

    def red(self):
        if self.plType == "global":
            idx = self["streamlist"].getSelectedIndex()
            self.close([idx, "del", self.playList])

    def exit(self):
        self.close([-1, "", self.playList])

    def ok(self):
        if len(self.playList) == 0:
            self.exit()
        idx = self["streamlist"].getSelectedIndex()
        self.close([idx, "", self.playList])

    def resetEvent(self):
        print "resetEvent:"
        if self.event:
            self.event.reset()
示例#14
0
	def __init__(self, session, playList, playIdx=0, playAll=False, listTitle=None, plType='local', title_inr=0, cover=False, ltype='', autoScrSaver=False, showPlaylist=True, listEntryPar=None, playList2=[], playerMode='VIDEO'):
		try:
			from enigma import eServiceMP3
		except:
			is_eServiceMP3 = False
			print "No MP3 service"
		else:
			is_eServiceMP3 = True
			print "MP3 service imported"

		Screen.__init__(self, session)
		print "SimplePlayer:"
		self.session = session
		self.plugin_path = "/usr/lib/enigma2/python/Plugins/Extensions/supportchannel"
		self.skin_path = "/usr/lib/enigma2/python/Plugins/Extensions/supportchannel" + "/skins"
		self.wallicon_path = "/usr/lib/enigma2/python/Plugins/Extensions/supportchannel" + "/icons_wall/"

		path = "%s/simpleplayer/SimplePlayer.xml" % self.skin_path
		with open(path, "r") as f:
			self.skin = f.read()
			f.close()

		self.setActionPrio()
		self["actions"] = ActionMap(["WizardActions",'MediaPlayerSeekActions',"EPGSelectActions",'MoviePlayerActions','ColorActions','InfobarActions',"MenuActions","HelpActions"],
		{
			"leavePlayer": self.leavePlayer,
			config.supportchannel.sp_mi_key.value: self.openMediainfo,
			"menu":		self.openMenu,
			"up": 		self.openPlaylist,
			"down":		self.randomNow,
			"back":		self.leavePlayer,
			"left":		self.seekBack,
			"right":	self.seekFwd,
			"seekdef:1": self.Key1,
			"seekdef:3": self.Key3,
			"seekdef:4": self.Key4,
			"seekdef:6": self.Key6,
			"seekdef:7": self.Key7,
			"seekdef:9": self.Key9

		}, self.action_prio)

		SimpleSeekHelper.__init__(self)
		SimplePlayerResume.__init__(self)
		InfoBarMenu.__init__(self)
		InfoBarNotifications.__init__(self)
		InfoBarServiceNotifications.__init__(self)
		InfoBarBase.__init__(self)
		InfoBarShowHide.__init__(self)
		InfoBarAudioSelection.__init__(self)
		InfoBarSubtitleSupport.__init__(self)
		InfoBarSimpleEventView.__init__(self)

		self.allowPiP = False
		InfoBarSeek.__init__(self)
		InfoBarPVRState.__init__(self)

		self.skinName = 'MediaPortal SimplePlayer'
		self.lastservice = self.session.nav.getCurrentlyPlayingServiceReference()

		self.playerMode = playerMode
		self.keyPlayNextLocked = False
		self.isTSVideo = False
		self.showGlobalPlaylist = True
		self.showPlaylist = showPlaylist
		self.scrSaver = ''
		self.saverActive = False
		self.autoScrSaver = autoScrSaver
		self.pl_open = False
		self.playMode = [str(config.supportchannel.sp_playmode.value)]
		self.listTitle = listTitle
		self.playAll = playAll
		self.playList = playList
		self.playIdx = playIdx
		if plType == 'local':
			self.playLen = len(playList)
		else:
			self.playLen = len(playList2)

		self.listEntryPar=listEntryPar
		self.returning = False
		self.pl_entry = ['', '', '', '', '', '', '', '', '']
		self.plType = plType
		self.playList2 = playList2
		self.pl_name = 'mp_global_pl_%02d' % config.supportchannel.sp_pl_number.value
		self.title_inr = title_inr
		self.cover = cover
		self.ltype = ltype
		self.playlistQ = Queue.Queue(0)
		self.pl_status = (0, '', '', '', '', '')
		self.pl_event = SimpleEvent()
		self['spcoverframe'] = Pixmap()
		self['spcoverfg'] = Pixmap()
		self['Icon'] = Pixmap()
		self._Icon = CoverHelper(self['Icon'])
		self['premiumizemeoff'] = Pixmap()
		self['premiumizemeon'] = Pixmap()
		self['premiumizemeon'].hide()

		# load default cover
		self['Cover'] = Pixmap()
		self._Cover = CoverHelper(self['Cover'], nc_callback=self.hideSPCover)
		self.coverBGisHidden = False
		self.cover2 = False

		self.SaverTimer = eTimer()
		self.SaverTimer.callback.append(self.openSaver)

		self.hideSPCover()
		self.configSaver()
		self.onClose.append(self.playExit)
		self.onFirstExecBegin.append(self.showIcon)
		self.onFirstExecBegin.append(self.playVideo)

		if self.playerMode in 'MP3':
			self.onFirstExecBegin.append(self.openPlaylist)

		if is_eServiceMP3:
			self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
				{
					eServiceMP3.evAudioDecodeError: self.__evAudioDecodeError,
					eServiceMP3.evVideoDecodeError: self.__evVideoDecodeError,
					eServiceMP3.evPluginError: self.__evPluginError,
					eServiceMP3.evStreamingSrcError: self.__evStreamingSrcError
				})
示例#15
0
	def __init__(self, session, playList, playIdx=0, playAll=False, listTitle=None, plType='local', title_inr=0, cover=False, ltype='', autoScrSaver=False, showPlaylist=True, listEntryPar=None, playList2=[]):
		try:
			from enigma import eServiceMP3
		except:
			is_eServiceMP3 = False
			print "No MP3 service"
		else:
			is_eServiceMP3 = True
			print "MP3 service imported"

		Screen.__init__(self, session)
		print "SimplePlayer:"
		self.session = session
		self.plugin_path = mp_globals.pluginPath
		self.skin_path = mp_globals.pluginPath + "/skins"
		self.wallicon_path = mp_globals.pluginPath + "/icons_wall/"

		path = "%s/simpleplayer/SimplePlayer.xml" % self.skin_path
		with open(path, "r") as f:
			self.skin = f.read()
			f.close()

		self.setActionPrio()
		self["actions"] = ActionMap(["WizardActions",'MediaPlayerSeekActions',"EPGSelectActions",'MoviePlayerActions','ColorActions','InfobarActions',"MenuActions","HelpActions"],
		{
			"leavePlayer": self.leavePlayer,
			config.mediaportal.sp_mi_key.value: self.openMediainfo,
			"menu":		self.openMenu,
			"up": 		self.openPlaylist,
			"down":		self.randomNow,
			"back":		self.leavePlayer,
			"left":		self.seekBack,
			"right":	self.seekFwd,
			"seekdef:1": self.Key1,
			"seekdef:3": self.Key3,
			"seekdef:4": self.Key4,
			"seekdef:6": self.Key6,
			"seekdef:7": self.Key7,
			"seekdef:9": self.Key9

		}, self.action_prio)

		SimpleSeekHelper.__init__(self)
		InfoBarMenu.__init__(self)
		InfoBarNotifications.__init__(self)
		InfoBarServiceNotifications.__init__(self)
		InfoBarBase.__init__(self)
		InfoBarShowHide.__init__(self)
		InfoBarAudioSelection.__init__(self)
		InfoBarSubtitleSupport.__init__(self)
		InfoBarSimpleEventView.__init__(self)

		self.allowPiP = False
		InfoBarSeek.__init__(self)
		InfoBarPVRState.__init__(self)

		self.skinName = 'MediaPortal SimplePlayer'
		self.lastservice = self.session.nav.getCurrentlyPlayingServiceReference()

		self.isTSVideo = False
		self.showGlobalPlaylist = True
		self.showPlaylist = showPlaylist
		self.scrSaver = ''
		self.saverActive = False
		self.autoScrSaver = autoScrSaver
		self.pl_open = False
		self.randomPlay = False
		self.playMode = ""
		self.listTitle = listTitle
		self.playAll = playAll
		self.playList = playList
		self.playIdx = playIdx
		if plType == 'local':
			self.playLen = len(playList)
		else:
			self.playLen = len(playList2)

		self.listEntryPar=listEntryPar
		self.returning = False
		self.pl_entry = ['', '', '', '', '', '', '', '', '']
		self.plType = plType
		self.playList2 = playList2
		self.pl_name = 'mp_global_pl_%02d' % config.mediaportal.sp_pl_number.value
		self.title_inr = title_inr
		self.cover = cover
		self.ltype = ltype
		self.playlistQ = Queue.Queue(0)
		self.pl_status = (0, '', '', '', '', '')
		self.pl_event = SimpleEvent()
		self['spcoverframe'] = Pixmap()
		self['spcoverfg'] = Pixmap()
		self['Icon'] = Pixmap()
		self._Icon = CoverHelper(self['Icon'])
		self['premiumizemeoff'] = Pixmap()
		self['premiumizemeon'] = Pixmap()
		self['premiumizemeon'].hide()

		# load default cover
		self['Cover'] = Pixmap()
		self._Cover = CoverHelper(self['Cover'], nc_callback=self.hideSPCover)
		self.coverBGisHidden = False
		self.cover2 = False

		self.SaverTimer = eTimer()
		self.SaverTimer.callback.append(self.openSaver)

		self.hideSPCover()
		self.setPlaymode()
		self.configSaver()
		self.onClose.append(self.playExit)
		self.onFirstExecBegin.append(self.showIcon)
		self.onFirstExecBegin.append(self.playVideo)

		if is_eServiceMP3:
			self.__event_tracker = ServiceEventTracker(screen=self, eventmap=
				{
					eServiceMP3.evAudioDecodeError: self.__evAudioDecodeError,
					eServiceMP3.evVideoDecodeError: self.__evVideoDecodeError,
					eServiceMP3.evPluginError: self.__evPluginError,
					eServiceMP3.evStreamingSrcError: self.__evStreamingSrcError
				})
示例#16
0
 def showInfos(self):
     url_cover = self['liste'].getCurrent()[0][1]
     CoverHelper(self['coverArt']).getCover(url_cover)
示例#17
0
class SimplePlayer(
    Screen,
    SimpleSeekHelper,
    InfoBarBase,
    InfoBarSeek,
    InfoBarNotifications,
    InfoBarShowHide,
    InfoBarAudioSelection,
    InfoBarSubtitleSupport,
):
    ENABLE_RESUME_SUPPORT = True
    ALLOW_SUSPEND = True

    def __init__(
        self,
        session,
        playList,
        playIdx=0,
        playAll=False,
        listTitle=None,
        plType="local",
        title_inr=0,
        cover=False,
        ltype="",
        autoScrSaver=False,
        showPlaylist=True,
    ):

        Screen.__init__(self, session)
        print "SimplePlayer:"
        self.session = session
        self.plugin_path = mp_globals.pluginPath
        self.skin_path = mp_globals.pluginPath + "/skins"
        self.wallicon_path = mp_globals.pluginPath + "/icons_wall/"

        path = "%s/tec/SimplePlayer.xml" % self.skin_path
        with open(path, "r") as f:
            self.skin = f.read()
            f.close()

        self["actions"] = ActionMap(
            [
                "WizardActions",
                "MediaPlayerSeekActions",
                "EPGSelectActions",
                "MoviePlayerActions",
                "ColorActions",
                "InfobarActions",
            ],
            {
                "leavePlayer": self.leavePlayer,
                "info": self.openMediainfo,
                "input_date_time": self.openMenu,
                "up": self.openPlaylist,
                "down": self.randomNow,
                "back": self.leavePlayer,
                "left": self.seekBack,
                "right": self.seekFwd,
            },
            -1,
        )

        SimpleSeekHelper.__init__(self)
        InfoBarNotifications.__init__(self)
        # InfoBarServiceNotifications.__init__(self)
        InfoBarBase.__init__(self)
        InfoBarShowHide.__init__(self)
        InfoBarAudioSelection.__init__(self)
        InfoBarSubtitleSupport.__init__(self)

        self.allowPiP = False
        InfoBarSeek.__init__(self)

        self.skinName = "MediaPortal SimplePlayer"
        self.lastservice = self.session.nav.getCurrentlyPlayingServiceReference()

        self.showPlaylist = showPlaylist
        self.scrSaver = ""
        self.saverActive = False
        self.autoScrSaver = autoScrSaver
        self.pl_open = False
        self.randomPlay = False
        self.playMode = ""
        self.listTitle = listTitle
        self.playAll = playAll
        self.playList = playList
        self.playIdx = playIdx
        self.playLen = len(playList)
        self.returning = False
        self.pl_entry = ["", "", "", "", "", "", "", "", ""]
        self.plType = plType
        self.playList2 = []
        self.pl_name = "mp_global_pl_01"
        self.title_inr = title_inr
        self.cover = cover
        self.ltype = ltype
        self.playlistQ = Queue.Queue(0)
        self.pl_status = (0, "", "", "", "")
        self.pl_event = SimpleEvent()
        self["spcoverframe"] = Pixmap()
        self["spcoverfg"] = Pixmap()
        self["Icon"] = Pixmap()
        self._Icon = CoverHelper(self["Icon"])

        # load default cover
        self["Cover"] = Pixmap()
        self._Cover = CoverHelper(self["Cover"], nc_callback=self.hideSPCover)
        self.cover_is_hidden = False

        self.SaverTimer = eTimer()
        self.SaverTimer.callback.append(self.openSaver)

        self.setPlaymode()
        self.configSaver()
        self.onClose.append(self.playExit)
        self.onFirstExecBegin.append(self.showIcon)
        self.onLayoutFinish.append(self.getVideo)

    def playVideo(self):
        print "playVideo:"
        if self.seekBarLocked:
            self.cancelSeek()
        if self.plType == "global":
            self.getVideo2()
        else:
            self.getVideo()

    def dataError(self, error):
        print "dataError:"
        printl(error, self, "E")
        self.playNextStream(config.mediaportal.sp_on_movie_eof.value)

    def playStream(self, title, url=None, album="", artist="", imgurl=""):
        print "playStream: ", title, url
        if not url:
            return

        if self.cover:
            self.showCover(imgurl)

        sref = eServiceReference(0x1001, 0, url)

        pos = title.find(". ", 0, 5)
        if pos > 0:
            pos += 2
            title = title[pos:]

        if artist != "":
            sref.setName(artist + " - " + title)
        else:
            sref.setName(title)

        if self.cover:
            cflag = "1"
        else:
            cflag = "0"

        self.pl_entry = [title, None, artist, album, self.ltype, "", imgurl, cflag]
        self.session.nav.stopService()
        self.session.nav.playService(sref)

        self.pl_status = (self.playIdx, title, artist, album, imgurl, self.plType)
        if self.pl_open:
            self.playlistQ.put(self.pl_status)
            self.pl_event.genEvent()

    def playPrevStream(self):
        print "_prevStream:"
        if not self.playAll or self.playLen <= 1:
            self.handleLeave(config.mediaportal.sp_on_movie_stop.value)
        else:
            if self.playIdx > 0:
                self.playIdx -= 1
            else:
                self.playIdx = self.playLen - 1
            self.playVideo()

    def playNextStream(self, value):
        print "playNextStream:"
        if not self.playAll or self.playLen <= 1:
            self.handleLeave(value)
        else:
            if self.playIdx in range(0, self.playLen - 1):
                self.playIdx += 1
            else:
                self.playIdx = 0
            self.playVideo()

    def playRandom(self, value):
        print "playRandom:"
        if self.playLen > 1 and self.playAll:
            self.playIdx = random.randint(0, self.playLen - 1)
            self.playVideo()
        else:
            self.handleLeave(value)

    def randomNow(self):
        if self.playAll:
            self.playRandom(config.mediaportal.sp_on_movie_stop.value)

    def seekFwd(self):
        if self.seekBarShown and not self.seekBarLocked:
            self.initSeek()
        elif self.seekBarLocked:
            self.seekRight()
        elif self.playAll:
            self.playNextStream(config.mediaportal.sp_on_movie_stop.value)

    def seekBack(self):
        if self.seekBarShown and not self.seekBarLocked:
            self.initSeek()
        elif self.seekBarLocked:
            self.seekLeft()
        elif self.playAll:
            self.playPrevStream()

    def handleLeave(self, how):
        print "handleLeave:"
        self.is_closing = True
        if how == "ask":
            if self.plType == "local":
                list = (
                    (_("Yes"), "quit"),
                    (_("Ja & Service zur glob. Playlist hinzufügen"), "add"),
                    (_("No"), "continue"),
                    (_("No, but restart from begin"), "restart"),
                )
            else:
                list = ((_("Yes"), "quit"), (_("No"), "continue"), (_("No, but restart from begin"), "restart"))

            from Screens.ChoiceBox import ChoiceBox

            self.session.openWithCallback(
                self.leavePlayerConfirmed, ChoiceBox, title=_("Stop playing this movie?"), list=list
            )
        else:
            self.leavePlayerConfirmed([True, how])

    def leavePlayerConfirmed(self, answer):
        print "leavePlayerConfirmed:"
        answer = answer and answer[1]
        print answer

        if answer in ("quit", "movielist"):
            self.close()
        elif answer == "restart":
            self.doSeek(0)
            self.setSeekState(self.SEEK_STATE_PLAY)
        elif answer == "add":
            self.addToPlaylist()
            self.close()

    def leavePlayer(self):
        print "leavePlayer:"
        if self.seekBarLocked:
            self.cancelSeek()
        else:
            self.handleLeave(config.mediaportal.sp_on_movie_stop.value)

    def doEofInternal(self, playing):
        print "doEofInt:"
        if playing:
            if self.randomPlay:
                self.playRandom(config.mediaportal.sp_on_movie_eof.value)
            else:
                self.playNextStream(config.mediaportal.sp_on_movie_eof.value)

    def playExit(self):
        print "playExit:"
        self.SaverTimer.stop()
        self.session.nav.playService(self.lastservice)

    def getVideo(self):
        print "getVideo:"
        title = self.playList[self.playIdx][0]
        url = self.playList[self.playIdx][1]
        if len(self.playList[0]) == 3:
            iurl = self.playList[self.playIdx][2]
        else:
            iurl = ""
        self.playStream(title, url, imgurl=iurl)

    def getVideo2(self):
        print "getVideo2:"
        if self.playLen > 0:
            titel = self.playList2[self.playIdx][1]
            url = self.playList2[self.playIdx][2]
            album = self.playList2[self.playIdx][3]
            artist = self.playList2[self.playIdx][4]
            imgurl = self.playList2[self.playIdx][7]
            if len(self.playList2[self.playIdx]) < 6:
                ltype = ""
            else:
                ltype = self.playList2[self.playIdx][5]

            if ltype == "youtube":
                YoutubeLink(self.session).getLink(self.playStream, self.dataError, titel, url, imgurl)
            elif ltype == "putpattv":
                token = self.playList2[self.playIdx][6]
                PutpattvLink(self.session).getLink(self.playStream, self.dataError, titel, url, token, imgurl)
            elif ltype == "myvideo":
                token = self.playList2[self.playIdx][6]
                MyvideoLink(self.session).getLink(self.playStream, self.dataError, titel, url, token, imgurl)
            elif ltype == "songsto":
                token = self.playList2[self.playIdx][6]
                SongstoLink(self.session).getLink(self.playStream, self.dataError, titel, artist, album, token, imgurl)
            elif ltype == "canna":
                CannaLink(self.session).getLink(self.playStream, self.dataError, titel, artist, album, url, imgurl)
            elif ltype == "eighties":
                token = self.playList2[self.playIdx][6]
                EightiesLink(self.session).getLink(
                    self.playStream, self.dataError, titel, artist, album, url, token, imgurl
                )
            elif ltype == "mtv":
                MTVdeLink(self.session).getLink(self.playStream, self.dataError, titel, artist, url, imgurl)
            elif url:
                self.playStream(titel, url, album, artist, imgurl=imgurl)
        else:
            self.close()

    def openPlaylist(self):
        if self.showPlaylist and self.playLen > 0:
            if self.playlistQ.empty():
                self.playlistQ.put(self.pl_status)
            self.pl_open = True
            self.pl_event.genEvent()

            if self.plType == "local":
                self.session.openWithCallback(
                    self.cb_Playlist,
                    SimplePlaylist,
                    self.playList,
                    self.playIdx,
                    listTitle=self.listTitle,
                    plType=self.plType,
                    title_inr=self.title_inr,
                    queue=self.playlistQ,
                    mp_event=self.pl_event,
                )
            else:
                self.session.openWithCallback(
                    self.cb_Playlist,
                    SimplePlaylist,
                    self.playList2,
                    self.playIdx,
                    listTitle=None,
                    plType=self.plType,
                    title_inr=0,
                    queue=self.playlistQ,
                    mp_event=self.pl_event,
                )

    def cb_Playlist(self, data):
        self.pl_open = False

        while not self.playlistQ.empty():
            t = self.playlistQ.get_nowait()

        if data[0] != -1:
            self.playIdx = data[0]
            if self.plType == "global":
                if data[1] == "del":
                    self.session.nav.stopService()
                    SimplePlaylistIO.delEntry(self.pl_name, self.playList2, self.playIdx)
                    self.playLen = len(self.playList2)
                    if self.playIdx >= self.playLen:
                        self.playIdx -= 1
                    if self.playIdx < 0:
                        self.close()
                    else:
                        self.openPlaylist()
            self.playVideo()

    def openMediainfo(self):
        if MediainfoPresent:
            url = self.session.nav.getCurrentlyPlayingServiceReference().getPath()
            if url[:4] == "http":
                self.session.open(mediaInfo, True)

    def openMenu(self):
        self.session.openWithCallback(self.cb_Menu, SimplePlayerMenu, self.plType, self.showPlaylist)

    def cb_Menu(self, data):
        print "cb_Menu:"
        if data != []:
            if data[0] == 1:
                self.setPlaymode()
                self.configSaver()
            elif data[0] == 2:
                self.addToPlaylist()

            elif data[0] == 3:
                pl_list = SimplePlaylistIO.getPL(data[self.pl_name])
                if pl_list != []:
                    self.playList2 = pl_list
                    self.playIdx = 0
                    self.playLen = len(self.playList2)
                    self.plType = "global"
                    self.openPlaylist()

            elif data[0] == 4:
                if self.plType != "local":
                    self.plType = "local"
                    self.playIdx = 0
                    self.playLen = len(self.playList)
                    self.playList2 = []
                if self.playLen > 0:
                    self.openPlaylist()

    def addToPlaylist(self):
        if self.plType != "local":
            self.session.open(
                MessageBox,
                _("Fehler: Service darf nur von der lok. PL hinzugefügt werden"),
                MessageBox.TYPE_INFO,
                timeout=5,
            )
            return

        if self.pl_entry[4] == "youtube":
            url = self.playList[self.playIdx][2]
        elif self.pl_entry[4] == "myvideo":
            url = self.playList[self.playIdx][1]
            self.pl_entry[5] = self.playList[self.playIdx][2]
        elif self.pl_entry[4] == "mtv":
            url = self.playList[self.playIdx][1]
        else:
            url = self.session.nav.getCurrentlyPlayingServiceReference().getPath()

            if re.match(".*?(putpattv)", url, re.I):
                self.session.open(MessageBox, _("Fehler: URL ist nicht persistent !"), MessageBox.TYPE_INFO, timeout=5)
                return

        self.pl_entry[1] = url
        res = SimplePlaylistIO.addEntry(self.pl_name, self.pl_entry)
        if res == 1:
            self.session.open(MessageBox, _("Eintrag hinzugefügt"), MessageBox.TYPE_INFO, timeout=5)
        elif res == 0:
            self.session.open(MessageBox, _("Eintrag schon vorhanden"), MessageBox.TYPE_INFO, timeout=5)
        else:
            self.session.open(MessageBox, _("Fehler!"), MessageBox.TYPE_INFO, timeout=5)

    def showCover(self, cover):
        print "showCover:", cover
        if self.cover_is_hidden:
            self.showSPCover()
        self._Cover.getCover(cover)

    def showIcon(self):
        print "showIcon:"
        if not self.cover:
            self.hideSPCover()
        pm_file = self.wallicon_path + mp_globals.activeIcon + ".png"
        self._Icon.showCoverFile(pm_file)

    def hideSPCover(self):
        self["spcoverframe"].hide()
        self["spcoverfg"].hide()
        self.cover_is_hidden = True

    def showSPCover(self):
        self["spcoverframe"].show()
        self["spcoverfg"].show()
        self.cover_is_hidden = False

        # def lockShow(self):
        # 	pass

        # def unlockShow(self):
        # 	pass

    def configSaver(self):
        print "configSaver:"
        self.scrSaver = config.mediaportal.sp_scrsaver.value
        print "Savermode: ", self.scrSaver
        if self.scrSaver == "automatic" and self.autoScrSaver or self.scrSaver == "on":
            if not self.saverActive:
                self.SaverTimer.start(1000 * 60, True)
                self.saverActive = True
                print "scrsaver timer startet"
        else:
            self.SaverTimer.stop()
            self.saverActive = False

    def openSaver(self):
        print "openSaver:"
        self.session.openWithCallback(self.cb_Saver, SimpleScreenSaver)

    def cb_Saver(self):
        print "cb_Saver:"
        self.saverActive = False
        self.configSaver()

    def setPlaymode(self):
        print "setPlaymode:"
        self.randomPlay = config.mediaportal.sp_randomplay.value
        if self.randomPlay:
            self.playMode = "Random"
        else:
            self.playMode = "Next"