diff options
| author | 2011-04-07 15:19:18 +0200 | |
|---|---|---|
| committer | 2011-04-07 15:19:18 +0200 | |
| commit | 097abf81eb4cf10f26ad5c6aa485b06158eece2a (patch) | |
| tree | 8eab4eebf90bb89e390c6a0ff236a7a0a6713696 | |
| parent | a348356b9d7bc856465431965509cae99231809b (diff) | |
| download | totem-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.py | 52 | ||||
| -rw-r--r-- | airplay.py | 3 | 
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):  		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 = '<?xml version="1.0" encoding="UTF-8"?>\ +<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">\ +<plist version="1.0">\ +<dict>\ +<key>duration</key>\ +<real>%f</real>\ +<key>position</key>\ +<real>%f</real>\ +<key>rate</key>\ +<real>%f</real>\ +<key>playbackBufferEmpty</key>\ +<%s/>\ +<key>playbackBufferFull</key>\ +<false/>\ +<key>playbackLikelyToKeepUp</key>\ +<true/>\ +<key>readyToPlay</key>\ +<%s/>\ +<key>loadedTimeRanges</key>\ +<array>\ +    <dict>\ +        <key>duration</key>\ +        <real>%f</real>\ +        <key>start</key>\ +        <real>0.000000</real>\ +    </dict>\ +</array>\ +<key>seekableTimeRanges</key>\ +<array>\ +    <dict>\ +        <key>duration</key>\ +        <real>%f</real>\ +        <key>start</key>\ +        <real>0.000000</real>\ +    </dict>\ +</array>\ +</dict>\ +</plist>' +			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() @@ -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(): | 
