From 097abf81eb4cf10f26ad5c6aa485b06158eece2a Mon Sep 17 00:00:00 2001 From: Martin Szulecki Date: Thu, 7 Apr 2011 15:19:18 +0200 Subject: Implement playback-info request to fix playback on iOS 4.3+ --- AirPlayService.py | 52 +++++++++++++++++++++++++++++++++++++++++++++++++++- airplay.py | 3 +++ 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/AirPlayService.py b/AirPlayService.py index 394c434..b6f6ae3 100644 --- a/AirPlayService.py +++ b/AirPlayService.py @@ -94,7 +94,57 @@ class AirPlayProtocolHandler(asyncore.dispatcher_with_send): answer = "" # process the request and run the appropriate callback - if (request.uri.find('/play')>-1): + if (request.uri.find('/playback-info')>-1): + self.playback_info() + content = '\ +\ +\ +\ +duration\ +%f\ +position\ +%f\ +rate\ +%f\ +playbackBufferEmpty\ +<%s/>\ +playbackBufferFull\ +\ +playbackLikelyToKeepUp\ +\ +readyToPlay\ +<%s/>\ +loadedTimeRanges\ +\ + \ + duration\ + %f\ + start\ + 0.000000\ + \ +\ +seekableTimeRanges\ +\ + \ + duration\ + %f\ + start\ + 0.000000\ + \ +\ +\ +' + d, p = self.service.get_scrub() + if (d+p == 0): + playbackBufferEmpty = 'true' + readyToPlay = 'false' + else: + playbackBufferEmpty = 'false' + readyToPlay = 'true' + + content = content % (float(d), float(p), int(self.service.is_playing()), playbackBufferEmpty, readyToPlay, float(d), float(d)) + answer = self.create_request(200, "Content-Type: text/x-apple-plist+xml", content) + elif (request.uri.find('/play')>-1): parsedbody = request.parse_headers(request.body.splitlines()) self.service.play(parsedbody['Content-Location'], float(parsedbody['Start-Position'])) answer = self.create_request() diff --git a/airplay.py b/airplay.py index 3e6266b..e2906c0 100644 --- a/airplay.py +++ b/airplay.py @@ -54,6 +54,9 @@ class AirPlayTotemPlayer(AirPlayService): position = float(self.totem.get_property('current-time') / 1000) return duration, position + def is_playing(self): + return self.totem.is_playing() + # this must seek to a certain time def set_scrub(self, position): if self.totem.is_seekable(): -- cgit v1.1-32-gdbae