示例#1
0
 def __init__(self, session):
     self.session = session
     self.callbacks = APCallbacks()
     self.callbacks.photo = self.__photo
     self.callbacks.audio = self.__audio
     self.callbacks.video = self.__video
     self.callbacks.videoPlay = self.__videoPlay
     self.callbacks.videoPause = self.__videoPause
     self.callbacks.videoGetPosition = self.__videoGetPosition
     self.callbacks.videoSetPosition = self.__videoSetPosition
     self.callbacks.stop = self.__close
     self.callbacks.stopAudio = self.__closeAudio
     self.server = APServer(self.callbacks)
     self.current = None
     self.videorequest = False
     self.videourl = ""
	def __init__(self, session):
		self.session = session
		self.callbacks = APCallbacks()
		self.callbacks.photo = self.__photo
		self.callbacks.audio = self.__audio
		self.callbacks.video = self.__video
		self.callbacks.videoPlay = self.__videoPlay
		self.callbacks.videoPause = self.__videoPause
		self.callbacks.videoGetPosition = self.__videoGetPosition
		self.callbacks.videoSetPosition = self.__videoSetPosition
		self.callbacks.stop = self.__close
		self.callbacks.stopAudio = self.__closeAudio
		self.server = APServer(self.callbacks)
		self.current = None
		self.videorequest = False
		self.videourl = ""
class AirPlay():
	def __init__(self, session):
		self.session = session
		self.callbacks = APCallbacks()
		self.callbacks.photo = self.__photo
		self.callbacks.audio = self.__audio
		self.callbacks.video = self.__video
		self.callbacks.videoPlay = self.__videoPlay
		self.callbacks.videoPause = self.__videoPause
		self.callbacks.videoGetPosition = self.__videoGetPosition
		self.callbacks.videoSetPosition = self.__videoSetPosition
		self.callbacks.stop = self.__close
		self.callbacks.stopAudio = self.__closeAudio
		self.server = APServer(self.callbacks)
		self.current = None
		self.videorequest = False
		self.videourl = ""
		
	def stop(self):
		self.server.stop()
		
	def start(self):
		self.server.start()
		
	def __photo(self, data):
		if self.current is None:
			self.current = self.session.open(AirPlayPhoto)
			
		if self.current.__class__.__name__ != "AirPlayPhoto":
			print "[SIFTeam OpenAirPlay] is it busy with other contents?"
			return
			
		self.current.load(data)
		
	def __audioClosed(self):
		if self.videorequest:
			self.current = self.session.open(AirPlayVideo)
			self.current.open(self.videourl)
			self.videorequest = False
		
	def __audio(self):
		if self.current is None:
			self.current = self.session.openWithCallback(self.__audioClosed, AirPlayAudio)
		
	def __video(self, url, startposition):
		if self.current is None:
			self.current = self.session.open(AirPlayVideo)
			
		if self.current.__class__.__name__ != "AirPlayVideo":
			# if audio we replace it
			if self.current.__class__.__name__ == "AirPlayAudio":
				self.videourl = url
				self.videorequest = True
				self.current.exit()
				return
			else:
				print "[SIFTeam OpenAirPlay] is it busy with other contents?"
				return
			
		self.current.open(url)
		
	def __videoPlay(self):
		if self.current is not None and self.current.__class__.__name__ == "AirPlayVideo":
			self.current.play()
		
	def __videoPause(self):
		if self.current is not None and self.current.__class__.__name__ == "AirPlayVideo":
			self.current.pause()
		
	def __videoGetPosition(self):
		if self.current is not None and self.current.__class__.__name__ == "AirPlayVideo":
			return self.current.getPosition()
			
		return None
	
	def __videoSetPosition(self, position):
		if self.current is not None and self.current.__class__.__name__ == "AirPlayVideo":
			self.current.setPosition(position)
	
	def __close(self):
		if self.current is not None:
			self.current.exit()
			self.current = None
			self.videorequest = False
	
	def __closeAudio(self):
		if self.current is not None and self.current.__class__.__name__ == "AirPlayAudio":
			self.current.exit()
			self.current = None
示例#4
0
class AirPlay():
    def __init__(self, session):
        self.session = session
        self.callbacks = APCallbacks()
        self.callbacks.photo = self.__photo
        self.callbacks.audio = self.__audio
        self.callbacks.video = self.__video
        self.callbacks.videoPlay = self.__videoPlay
        self.callbacks.videoPause = self.__videoPause
        self.callbacks.videoGetPosition = self.__videoGetPosition
        self.callbacks.videoSetPosition = self.__videoSetPosition
        self.callbacks.stop = self.__close
        self.callbacks.stopAudio = self.__closeAudio
        self.server = APServer(self.callbacks)
        self.current = None
        self.videorequest = False
        self.videourl = ""

    def stop(self):
        self.server.stop()

    def start(self):
        self.server.start()

    def __photo(self, data):
        if self.current is None:
            self.current = self.session.open(AirPlayPhoto)

        if self.current.__class__.__name__ != "AirPlayPhoto":
            print "[SIFTeam OpenAirPlay] is it busy with other contents?"
            return

        self.current.load(data)

    def __audioClosed(self):
        if self.videorequest:
            self.current = self.session.open(AirPlayVideo)
            self.current.open(self.videourl)
            self.videorequest = False

    def __audio(self):
        if self.current is None:
            self.current = self.session.openWithCallback(
                self.__audioClosed, AirPlayAudio)

    def __video(self, url, startposition):
        if self.current is None:
            self.current = self.session.open(AirPlayVideo)

        if self.current.__class__.__name__ != "AirPlayVideo":
            # if audio we replace it
            if self.current.__class__.__name__ == "AirPlayAudio":
                self.videourl = url
                self.videorequest = True
                self.current.exit()
                return
            else:
                print "[SIFTeam OpenAirPlay] is it busy with other contents?"
                return

        self.current.open(url)

    def __videoPlay(self):
        if self.current is not None and self.current.__class__.__name__ == "AirPlayVideo":
            self.current.play()

    def __videoPause(self):
        if self.current is not None and self.current.__class__.__name__ == "AirPlayVideo":
            self.current.pause()

    def __videoGetPosition(self):
        if self.current is not None and self.current.__class__.__name__ == "AirPlayVideo":
            return self.current.getPosition()

        return None

    def __videoSetPosition(self, position):
        if self.current is not None and self.current.__class__.__name__ == "AirPlayVideo":
            self.current.setPosition(position)

    def __close(self):
        if self.current is not None:
            self.current.exit()
            self.current = None
            self.videorequest = False

    def __closeAudio(self):
        if self.current is not None and self.current.__class__.__name__ == "AirPlayAudio":
            self.current.exit()
            self.current = None