def seekToStartPos(self): time = 0 try: if self.start is not None and config.plugins.airplayer.setSeekOnStart.value: service = self.session.nav.getCurrentService() seek = service and service.seek() if seek != None: r = seek.getLength() if not r[0]: print '[AirPlayMoviePlayer] got duration' if r[1] == 0: print '[AirPlayMoviePlayer] duration 0' return length = r[1] r = seek.getPlayPosition() if not r[0]: print 'playbacktime ', r[1] if r[1] < 90000: print 'do not seek yet', r[1] return else: return time = length * self.start print '[AirPlayMoviePlayer] seeking to', time, ' length ', length, '' self.start = None if time < 2700000: print '[AirPlayMoviePlayer] skip seeking < 30s' return blockingCallFromMainThread(self.doSeek, int(time)) except Exception: pass
def seekToStartPos(self): time = 0 try: if self.start is not None and config.plugins.airplayer.setSeekOnStart.value: service = self.session.nav.getCurrentService() seek = service and service.seek() if seek != None: r = seek.getLength() if not r[0]: print '[AirPlayMoviePlayer] got duration' if r[1] == 0: print '[AirPlayMoviePlayer] duration 0' return length = r[1] r = seek.getPlayPosition() if not r[0]: print 'playbacktime ', r[1] if r[1] < 90000: print 'do not seek yet', r[1] return else: return time = length * self.start print '[AirPlayMoviePlayer] seeking to', time, ' length ', length, '' self.start = None if time < 2700000: print '[AirPlayMoviePlayer] skip seeking < 30s' return blockingCallFromMainThread(self.doSeek, int(time)) except Exception: pass
def proxyWatcher(self, *args): print '[AirPlayMoviePlayer] proxy starting ....' self.liveStream = False self.m3u8Stream = False try: args = [PROXY_BINARY, self.url, config.plugins.airplayer.validationKey.value, config.plugins.airplayer.path.value] print 'starting proxy' print args[0], args[1] self.proxyProcess = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE) print '[AirPlayMoviePlayer] proxy started ....' while self.proxyProcess.poll() == None: buff = self.proxyProcess.stdout.readline() self.proxyReady = True if len(buff) > 0: if buff[:6] == 'rpos: ': percent = int(buff[6:]) blockingCallFromMainThread(self['bufferslider'].setValue, percent) if not self.liveStream and percent == 100: self.proxyCaching = False elif buff[:7] == 'cache: ': kb = int(buff[7:]) mb = kb / 1024 blockingCallFromMainThread(self['label_cache'].setText, 'Cache: ' + self.formatKB(kb * 1024, 'B', 1)) print '[AirPlayMoviePlayer] cache is at ', mb, ' MB' if self.liveStream == True and mb >= config.plugins.airplayer.cacheMbBeforeLivePlayback.value and self.startNewServiceOnPlay: self.proxyCaching = False if self.liveStream == False and mb >= config.plugins.airplayer.cacheMbBeforePlayback.value and self.startNewServiceOnPlay: self.proxyCaching = False elif buff[:19] == 'playing livestream!': self.liveStream = True print '[AirPlayMoviePlayer] playing livestream!' elif buff[:13] == 'playing m3u8!': self.m3u8Stream = True print '[AirPlayMoviePlayer] playing m3u8 stream!' elif buff[:8] == 'rspeed: ': rspeed = int(buff[8:]) * 1000 blockingCallFromMainThread(self['label_speed'].setText, 'DL-Speed: ' + self.formatKBits(rspeed)) elif buff[:7] == 'Error: ': blockingCallFromMainThread(Notifications.AddNotification, MessageBox, _('The Proxy encountered an Error: %s, starting direct playback now!') % buff[7:], type=MessageBox.TYPE_INFO, timeout=10) self.proxyError = True self.proxyCaching = False else: print '[AirPlayMoviePlayer] Proxy: ', buff print '[AirPlayMoviePlayer] proxy done' except Exception as e: print '[AirPlayMoviePlayer] error in proxy: ', e traceback.print_exc() if self.proxyCaching == True: blockingCallFromMainThread(Notifications.AddNotification, MessageBox, _('Starting the Proxy failed: %s, starting direct playback now!') % e, type=MessageBox.TYPE_INFO, timeout=10) self.proxyError = True self.proxyCaching = False else: print '[AirPlayMoviePlayer] assume error comes from killing process after eof ' print '[AirPlayMoviePlayer] proxy thread done'
def checkForUpdate(self, *args): url = self.backend.updater.checkForUpdate(self.url, 1) if url != '' and url != 'up to date': blockingCallFromMainThread(self['label_update'].setText, 'Update Available')
def proxyWatcher(self, *args): print '[AirPlayMoviePlayer] proxy starting ....' self.liveStream = False self.m3u8Stream = False try: args = [ PROXY_BINARY, self.url, config.plugins.airplayer.validationKey.value, config.plugins.airplayer.path.value ] print 'starting proxy' print args[0], args[1] self.proxyProcess = subprocess.Popen(args, stdin=subprocess.PIPE, stdout=subprocess.PIPE) print '[AirPlayMoviePlayer] proxy started ....' while self.proxyProcess.poll() == None: buff = self.proxyProcess.stdout.readline() self.proxyReady = True if len(buff) > 0: if buff[:6] == 'rpos: ': percent = int(buff[6:]) blockingCallFromMainThread( self['bufferslider'].setValue, percent) if not self.liveStream and percent == 100: self.proxyCaching = False elif buff[:7] == 'cache: ': kb = int(buff[7:]) mb = kb / 1024 blockingCallFromMainThread( self['label_cache'].setText, 'Cache: ' + self.formatKB(kb * 1024, 'B', 1)) print '[AirPlayMoviePlayer] cache is at ', mb, ' MB' if self.liveStream == True and mb >= config.plugins.airplayer.cacheMbBeforeLivePlayback.value and self.startNewServiceOnPlay: self.proxyCaching = False if self.liveStream == False and mb >= config.plugins.airplayer.cacheMbBeforePlayback.value and self.startNewServiceOnPlay: self.proxyCaching = False elif buff[:19] == 'playing livestream!': self.liveStream = True print '[AirPlayMoviePlayer] playing livestream!' elif buff[:13] == 'playing m3u8!': self.m3u8Stream = True print '[AirPlayMoviePlayer] playing m3u8 stream!' elif buff[:8] == 'rspeed: ': rspeed = int(buff[8:]) * 1000 blockingCallFromMainThread( self['label_speed'].setText, 'DL-Speed: ' + self.formatKBits(rspeed)) elif buff[:7] == 'Error: ': blockingCallFromMainThread( Notifications.AddNotification, MessageBox, _('The Proxy encountered an Error: %s, starting direct playback now!' ) % buff[7:], type=MessageBox.TYPE_INFO, timeout=10) self.proxyError = True self.proxyCaching = False else: print '[AirPlayMoviePlayer] Proxy: ', buff print '[AirPlayMoviePlayer] proxy done' except Exception as e: print '[AirPlayMoviePlayer] error in proxy: ', e traceback.print_exc() if self.proxyCaching == True: blockingCallFromMainThread( Notifications.AddNotification, MessageBox, _('Starting the Proxy failed: %s, starting direct playback now!' ) % e, type=MessageBox.TYPE_INFO, timeout=10) self.proxyError = True self.proxyCaching = False else: print '[AirPlayMoviePlayer] assume error comes from killing process after eof ' print '[AirPlayMoviePlayer] proxy thread done'
def checkForUpdate(self, *args): url = self.backend.updater.checkForUpdate('AirTunes', 3) if url != '' and url != 'up to date': blockingCallFromMainThread(self['label_update'].setText, 'Update Available')