def getLength(self, service=None):
		#TODO read from meta eit
		#E2 will read / calculate it directly from ts file
		# Should stay dynamic if it is a copy or move
		#self.newService(service)
		
		# If it is a record we will force to use the timer duration
		length = 0
		if config.EMC.record_show_real_length.value:
			record = getRecording(self.path)
			if record:
				begin, end, service = record
				length = end - begin # times = (begin, end) : end - begin
			if length:
				return length
		service = service or self.__reference
		if self.isfile:
			#TODO isfile and isdvd
			esc = eServiceCenter.getInstance()
			info = esc and esc.info(service)
			length = info and info.getLength(service) or 0
		if length <= 0:
			length = self.__cutlist and self.__cutlist.getCutListLength()
		if length > 86400:
			length = 0
		return length or 0
    def getLength(self, service=None):
        #TODO read from meta eit
        #E2 will read / calculate it directly from ts file
        # Should stay dynamic if it is a copy or move
        #self.newService(service)

        # If it is a record we will force to use the timer duration
        length = 0
        if config.EMC.record_show_real_length.value:
            record = getRecording(self.path)
            if record:
                begin, end, service = record
                length = end - begin  # times = (begin, end) : end - begin
            if length:
                return length
        service = service or self.__reference
        if self.isfile:
            #TODO isfile and isdvd
            esc = eServiceCenter.getInstance()
            info = esc and esc.info(service)
            length = info and info.getLength(service) or 0
        if length <= 0:
            length = self.__cutlist and self.__cutlist.getCutListLength()
        if length > 86400:
            length = 0
        return length or 0
	def getPosition(self):
		if config.EMC.record_show_real_length.value:
			service = self.service
			path = service and service.getPath()
			if path:
				record = getRecording(path)
				if record:
					begin, end, s = record
					return int((time() - begin) * 90000)
		# Fallback
		seek = self.getSeek()
		if seek is None:
			return None
		pos = seek.getPlayPosition()
		if pos[0]:
			return 0
		return pos[1]
 def getPosition(self):
     if config.EMC.record_show_real_length.value:
         service = self.service
         path = service and service.getPath()
         if path:
             record = getRecording(path)
             if record:
                 begin, end, s = record
                 return int((time() - begin) * 90000)
     # Fallback
     seek = self.getSeek()
     if seek is None:
         return None
     pos = seek.getPlayPosition()
     if pos[0]:
         return 0
     return pos[1]
	def getLength(self):
		if config.EMC.record_show_real_length.value:
			service = self.service
			path = service and service.getPath()
			if path:
				record = getRecording(path)
				if record:
					#TODO There is still a problem with split records with cut numbers
					begin, end, s = record
					return int((end - begin) * 90000)
		# Fallback
		seek = self.getSeek()
		if seek is None:
			return None
		length = seek.getLength()
		if length[0]:
			return 0
		return length[1]
 def getLength(self):
     if config.EMC.record_show_real_length.value:
         service = self.service
         path = service and service.getPath()
         if path:
             record = getRecording(path)
             if record:
                 #TODO There is still a problem with split records with cut numbers
                 begin, end, s = record
                 return int((end - begin) * 90000)
     # Fallback
     seek = self.getSeek()
     if seek is None:
         return None
     length = seek.getLength()
     if length[0]:
         return 0
     return length[1]
	def doEofInternal(self, playing):
		print "EMC PLAYER doEofInternal"
		if not self.execing:
			return
		if not playing:
			return

		if self.in_menu:
			self.hide()
		val = config.EMC.record_eof_zap.value
		if val == "0" or val == "1" and self.service:
			#TEST
			# get path from iPlayableService
			#ref = self.session.nav.getCurrentlyPlayingServiceReference()
			#if ref and self.service and ref.getPath() == self.service.getPath():
			record = getRecording(self.service.getPath())
			if record:
				begin, end, service = record

				# Seek play position and record length differ about one second
				#last = ( time() - begin ) * 90000
				#if last < (self.getSeekPlayPosition() + 1*90000):

				# Zap to new channel
				self.lastservice = service
				self.service = None
				self.closeAll = True
				self.leavePlayer(False)
				return

				#TEST just return and ignore if there is more to play
				#else:
				##if self.seekstate == self.SEEK_STATE_EOF:
				##	self.setSeekState(self.SEEK_STATE_PLAY)
				#	return

		if self.service.type != sidDVB:
			self.makeUpdateCutList()

		self.evEOF()
    def doEofInternal(self, playing):
        print "EMC PLAYER doEofInternal"
        if not self.execing:
            return
        if not playing:
            return

        if self.in_menu:
            self.hide()
        if config.EMC.record_eof_zap.value and self.service:
            #TEST
            # get path from iPlayableService
            #ref = self.session.nav.getCurrentlyPlayingServiceReference()
            #if ref and self.service and ref.getPath() == self.service.getPath():
            record = getRecording(self.service.getPath())
            if record:
                begin, end, service = record

                # Seek play position and record length differ about one second
                #last = ( time() - begin ) * 90000
                #if last < (self.getSeekPlayPosition() + 1*90000):

                # Zap to new channel
                self.lastservice = service
                self.service = None
                self.closeAll = True
                self.leavePlayer(False)
                return

                #TEST just return and ignore if there is more to play
                #else:
                ##if self.seekstate == self.SEEK_STATE_EOF:
                ##	self.setSeekState(self.SEEK_STATE_PLAY)
                #	return

        if self.service.type != sidDVB:
            self.updateCutList(self.getSeekPlayPosition(),
                               self.getSeekLength())

        self.evEOF()
			f = None
			try:
				f = open(path, 'wb')
				if data:
					f.write(data)
			except Exception, e:
				emcDebugOut("[CUTS] Exception in __writeCutFile: " + str(e))
			finally:
				if f is not None:
					f.close()
			
			# [Cutlist.Workaround]
			# Always make a backup-copy when recording, it will be merged with enigma-cutfile after recording
			if DO_CUTLIST_WORKAROUND:
				recFileName=self.cut_file[:-5]
				record = getRecording(recFileName)
				if record:
					savepath = self.cut_file + ".save"
					fsave = None
					try:
						emcDebugOut("[Cutlist.Workaround] Creating backupfile: " + str(savepath))
						fsave = open(savepath, 'wb')
						if data:
							fsave.write(data)
					except Exception, e:
						emcDebugOut("[Cutlist.Workaround] Exception in __writeCutFile: " + str(e))
					finally:
						if fsave is not None:
							fsave.close()
					
			# Save file timestamp
    def evEOF(self, needToClose=False):
        # see if there are more to play
        print "EMC PLAYER evEOF", self.playall, self.playcount, self.playlist
        if self.playall:
            # Play All
            try:
                self.playcount = -1
                self.playlist = [self.playall.next()]
            except StopIteration:
                self.playall = None
                self.playlist = []

        if (self.playcount + 1) < len(self.playlist):
            self.playcount += 1
            service = self.playlist[self.playcount]
            #TODO Problem with VLC
            path = service and service.getPath()
            if os.path.exists(
                    path):  #TODO use ext != vlc but must be prepared first
                cutspath = path + ".cuts"
                if os.path.exists(cutspath):
                    # prepare cut list
                    #try:
                    #	# Workaround for not working E2 cue.setCutListEnable not working :-(
                    #	# We always have to set this permission, we can not detect all stop preview events
                    #	os.chmod(cutspath, 755)
                    #	print "EMC set chmod read and write"
                    #except:
                    #	pass
                    # Workaround for E2 dvb player bug in combination with running recordings and existings cutlists
                    record = getRecording(path)
                    if record:
                        try:
                            os.remove(cutspath)
                        except:
                            pass
                # Further cutlist handling
                toggleProgressService(service, True)
                self.service = service

                if service and service.type == sidDVD:
                    # Only import DVDPlayer, if we want to play a DVDPlayer format
                    if fileExists("%so" % dvdPlayerPlg) or fileExists(
                            "%sc" % dvdPlayerPlg):
                        try:
                            from Plugins.Extensions.DVDPlayer import servicedvd  # load c++ part of dvd player plugin
                        except:
                            pass
                        from Plugins.Extensions.DVDPlayer.plugin import DVDOverlay
                        if not self.dvdScreen:
                            self.dvdScreen = self.session.instantiateDialog(
                                DVDOverlay)
                    else:
                        self.session.open(MessageBox,
                                          _("No DVD-Player found!"),
                                          MessageBox.TYPE_ERROR, 10)
                        self.leavePlayer(True)
                        return
                    self["TeletextActions"].setEnabled(False)
                    self["DVDPlayerPlaybackActions"].setEnabled(True)
                else:
                    if self.dvdScreen:
                        self.dvdScreen.close()
                        self.dvdScreen = None
                    else:
                        self.dvdScreen = None
                    self["TeletextActions"].setEnabled(True)
                    self["DVDPlayerPlaybackActions"].setEnabled(False)

                # Check if the video preview is active and already running
        #				if config.EMC.movie_preview.value:
        #					ref = self.session.nav.getCurrentlyPlayingServiceReference()
        #					if ref and service and ref.getPath() == service.getPath():
        #						#s = self.session.nav.getCurrentService()
        #						#cue = s and s.cueSheet()
        #						#if cue is not None:
        #							#cue.setCutListEnable(1)
        #						self.downloadCuesheet()
        #							#print "EMC cue.setCutListEnable(1)"
        #						#return

        # Is this really necessary
        # TEST for M2TS Audio problem
        #self.session.nav.stopService()

        # Start playing movie
                self.session.nav.playService(service)

                if service and service.type == sidDVD:
                    # Seek will cause problems with DVDPlayer!
                    # ServiceDVD needs this to start
                    subs = self.getServiceInterface("subtitle")
                    if subs and self.dvdScreen:
                        subs.enableSubtitles(self.dvdScreen.instance, None)
                else:
                    # TEST for M2TS Audio problem
                    #self.setSeekState(InfoBarSeek.SEEK_STATE_PLAY)
                    #TODO Do we need this
                    #self.doSeek(0)
                    #TODO AutoSelect subtitle for DVD Player is not implemented yet
                    DelayedFunction(200, self.setAudioTrack)
                    DelayedFunction(400, self.setSubtitleState, True)
            else:
                self.session.open(
                    MessageBox,
                    _("Skipping movie, the file does not exist.\n\n") +
                    service.getPath(), MessageBox.TYPE_ERROR, 10)
                self.evEOF(needToClose)

        else:
            if needToClose or config.usage.on_movie_eof.value != "pause":
                self.closedByDelete = needToClose
                self.leavePlayer(False)
Exemplo n.º 11
0
	def evEOF(self, needToClose=False):
		# see if there are more to play
		print "EMC PLAYER evEOF", self.playall, self.playcount, self.playlist
		if self.playall:
			# Play All
			try:
				self.playcount = -1
				self.playlist = [ self.playall.next() ]
			except StopIteration:
				self.playall = None
				self.playlist = []
			
		if (self.playcount + 1) < len(self.playlist):
			self.playcount += 1
			service = self.playlist[self.playcount]
			#TODO Problem with VLC
			path = service and service.getPath()
			if os.path.exists(path): #TODO use ext != vlc but must be prepared first
				cutspath = path + ".cuts"
				if os.path.exists(cutspath):
					# prepare cut list
					#try:
					#	# Workaround for not working E2 cue.setCutListEnable not working :-(
					#	# We always have to set this permission, we can not detect all stop preview events
					#	os.chmod(cutspath, 755)
					#	print "EMC set chmod read and write"
					#except:
					#	pass
					# Workaround for E2 dvb player bug in combination with running recordings and existings cutlists
					record = getRecording(path)
					if record:
						try:
							os.remove(cutspath)
						except:
							pass
				# Further cutlist handling
				toggleProgressService(service, True)
				self.service = service
				
				if service and service.type == sidDVD:
					# Only import DVDPlayer, if we want to play a DVDPlayer format
					if fileExists("%so"%dvdPlayerPlg) or fileExists("%sc"%dvdPlayerPlg):
						try:
							from Plugins.Extensions.DVDPlayer import servicedvd # load c++ part of dvd player plugin
						except:
							pass
						from Plugins.Extensions.DVDPlayer.plugin import DVDOverlay
						if not self.dvdScreen:
							self.dvdScreen = self.session.instantiateDialog(DVDOverlay)
					else:
						self.session.open(MessageBox, _("No DVD-Player found!"), MessageBox.TYPE_ERROR, 10)
						self.leavePlayer(True)
						return
					self["TeletextActions"].setEnabled(False)
					self["DVDPlayerPlaybackActions"].setEnabled(True)
				else:
					if self.dvdScreen:
						self.dvdScreen.close()
						self.dvdScreen = None
					else:
						self.dvdScreen = None
					self["TeletextActions"].setEnabled(True)
					self["DVDPlayerPlaybackActions"].setEnabled(False)
				
				# Check if the video preview is active and already running
		#				if config.EMC.movie_preview.value:
		#					ref = self.session.nav.getCurrentlyPlayingServiceReference()
		#					if ref and service and ref.getPath() == service.getPath():
		#						#s = self.session.nav.getCurrentService()
		#						#cue = s and s.cueSheet()
		#						#if cue is not None:
		#							#cue.setCutListEnable(1)
		#						self.downloadCuesheet()
		#							#print "EMC cue.setCutListEnable(1)"
		#						#return
				
				# Is this really necessary 
				# TEST for M2TS Audio problem
				#self.session.nav.stopService() 
				
				# Start playing movie
				self.session.nav.playService(service)
				
				if service and service.type == sidDVD:
					# Seek will cause problems with DVDPlayer!
					# ServiceDVD needs this to start
					subs = self.getServiceInterface("subtitle")
					if subs and self.dvdScreen:
						subs.enableSubtitles(self.dvdScreen.instance, None)
				else:
					# TEST for M2TS Audio problem
					#self.setSeekState(InfoBarSeek.SEEK_STATE_PLAY)
					#TODO Do we need this
					#self.doSeek(0)
					#TODO AutoSelect subtitle for DVD Player is not implemented yet
					DelayedFunction(200, self.setAudioTrack)
					DelayedFunction(400, self.setSubtitleState, True)
			else:
				self.session.open(MessageBox, _("Skipping movie, the file does not exist.\n\n") + service.getPath(), MessageBox.TYPE_ERROR, 10)
				self.evEOF(needToClose)
				
		else:
			if needToClose or config.usage.on_movie_eof.value != "pause":
				self.closedByDelete = needToClose
				self.leavePlayer(False)