summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Martin Szulecki2011-04-07 15:19:18 +0200
committerGravatar Martin Szulecki2011-04-07 15:19:18 +0200
commit097abf81eb4cf10f26ad5c6aa485b06158eece2a (patch)
tree8eab4eebf90bb89e390c6a0ff236a7a0a6713696
parenta348356b9d7bc856465431965509cae99231809b (diff)
downloadtotem-plugin-airplay-097abf81eb4cf10f26ad5c6aa485b06158eece2a.tar.gz
totem-plugin-airplay-097abf81eb4cf10f26ad5c6aa485b06158eece2a.tar.bz2
Implement playback-info request to fix playback on iOS 4.3+
-rw-r--r--AirPlayService.py52
-rw-r--r--airplay.py3
2 files changed, 54 insertions, 1 deletions
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):
94 answer = "" 94 answer = ""
95 95
96 # process the request and run the appropriate callback 96 # process the request and run the appropriate callback
97 if (request.uri.find('/play')>-1): 97 if (request.uri.find('/playback-info')>-1):
98 self.playback_info()
99 content = '<?xml version="1.0" encoding="UTF-8"?>\
100<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\
101<plist version="1.0">\
102<dict>\
103<key>duration</key>\
104<real>%f</real>\
105<key>position</key>\
106<real>%f</real>\
107<key>rate</key>\
108<real>%f</real>\
109<key>playbackBufferEmpty</key>\
110<%s/>\
111<key>playbackBufferFull</key>\
112<false/>\
113<key>playbackLikelyToKeepUp</key>\
114<true/>\
115<key>readyToPlay</key>\
116<%s/>\
117<key>loadedTimeRanges</key>\
118<array>\
119 <dict>\
120 <key>duration</key>\
121 <real>%f</real>\
122 <key>start</key>\
123 <real>0.000000</real>\
124 </dict>\
125</array>\
126<key>seekableTimeRanges</key>\
127<array>\
128 <dict>\
129 <key>duration</key>\
130 <real>%f</real>\
131 <key>start</key>\
132 <real>0.000000</real>\
133 </dict>\
134</array>\
135</dict>\
136</plist>'
137 d, p = self.service.get_scrub()
138 if (d+p == 0):
139 playbackBufferEmpty = 'true'
140 readyToPlay = 'false'
141 else:
142 playbackBufferEmpty = 'false'
143 readyToPlay = 'true'
144
145 content = content % (float(d), float(p), int(self.service.is_playing()), playbackBufferEmpty, readyToPlay, float(d), float(d))
146 answer = self.create_request(200, "Content-Type: text/x-apple-plist+xml", content)
147 elif (request.uri.find('/play')>-1):
98 parsedbody = request.parse_headers(request.body.splitlines()) 148 parsedbody = request.parse_headers(request.body.splitlines())
99 self.service.play(parsedbody['Content-Location'], float(parsedbody['Start-Position'])) 149 self.service.play(parsedbody['Content-Location'], float(parsedbody['Start-Position']))
100 answer = self.create_request() 150 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):
54 position = float(self.totem.get_property('current-time') / 1000) 54 position = float(self.totem.get_property('current-time') / 1000)
55 return duration, position 55 return duration, position
56 56
57 def is_playing(self):
58 return self.totem.is_playing()
59
57 # this must seek to a certain time 60 # this must seek to a certain time
58 def set_scrub(self, position): 61 def set_scrub(self, position):
59 if self.totem.is_seekable(): 62 if self.totem.is_seekable():