diff options
| author | 2011-04-07 15:19:18 +0200 | |
|---|---|---|
| committer | 2011-04-07 15:19:18 +0200 | |
| commit | 097abf81eb4cf10f26ad5c6aa485b06158eece2a (patch) | |
| tree | 8eab4eebf90bb89e390c6a0ff236a7a0a6713696 /AirPlayService.py | |
| 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+
Diffstat (limited to 'AirPlayService.py')
| -rw-r--r-- | AirPlayService.py | 52 |
1 files changed, 51 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() |
