Issues with start position / seeking
drdaz opened this issue · comments
Hi there
I've been using Airplayer now for a couple of days. Really nice work!
I'm running into an issue though - when I start playing a video on XBMC, it always starts from the beginning. Likewise, when I move playback back to my iThing, it resumes at the last position played on the iThing (as in... not the position that was last played in XBMC).
I can see that the JSON-RPC calls are failing with 'Unable to parse' in the XBMC log:
22:34:06 T:3055549296 M:1410707456 ERROR: JSONRPC: Failed to parse '{
"id" : "uo9i98t3",
"jsonrpc" : "2.0",
"method" : "VideoPlayer.SeekTime",
"params" : 11
}
'
I changed the method field so that it matched the casing given in the spec, but it didn't help the issue... So the original videoplayer.seektime / seekpercentage calls failed in the same way. Any idea what might be going on here? I'm using an XBMC build from the pvr-testing branch from the source maintained by Lars Opdenkamp...
Cheers
/drdaz
If I'm not mistaken this issue has to do with this (now fixed) issue in XBMC:
Ok... I removed these 2 lines from jsonrpc.py to get playback to start from the correct place in XBMC:
if 'params' in obj and len(obj['params']) == 1:
obj['params'] = obj['params'][0]
However, this doesn't fix the issue with playback not starting at the correct place on the iThing (when returning playback from XBMC)... By the looks of things these are http api calls that are failing?
ERROR:root:Uncaught exception GET /playback-info (192.168.1.117)
HTTPRequest(protocol='http', host='127.0.0.1', method='GET', uri='/playback-info', version='HTTP/1.1', remote_ip='192.168.1.117', body='', headers={'X-Apple-Session-Id': '806c0ecd-c544-45a9-9089-ee4ab3fc23ef', 'Content-Length': '0', 'User-Agent': 'MediaControl/1.0'})
Traceback (most recent call last):
File "/usr/local/lib/python2.6/dist-packages/tornado/web.py", line 861, in _execute
getattr(self, self.request.method.lower())(_args, *_kwargs)
File "/src/Airplayer/Airplayer/airplayer/protocol_handler.py", line 271, in get
position, duration = self._media_backend.get_player_position()
File "/src/Airplayer/Airplayer/airplayer/mediabackends/XBMC_media_backend.py", line 234, in get_player_position
return int(response['time']), int(response['total'])
TypeError: int() argument must be a string or a number, not 'dict'
This error is repeated a lot.
Right... It seems that the object VideoPlayer.GetTime returns has changed in the newer builds of XBMC such that they contain hours, minutes, seconds and milliseconds. Now I've never coded any python before, but I've hacked this together, and it seems to fix the issue for me. I altered your get_player_position method in the XBMCMediaBackend as follows:
def get_player_position(self):
"""
Get the current videoplayer positon.
@returns int current position, int total length
"""
response, error = self._jsonrpc_api_request('videoplayer.gettime')
if not error:
if 'time' in response:
time = self.convert_time_to_int(response['time'])
total = self.convert_time_to_int(response['total'])
return int(time), int(total)
return None, None
def convert_time_to_int(self, time):
seconds = (time['seconds']) + (time['minutes'] * 60) + (time['hours'] * 3600)
return seconds
Are those builds final yet?
They are not. I suspect these changes will survive until the final release though. If they do, you've got the required patches here ;-)
On Jun 18, 2011, at 9:55 PM, PascalWreply@reply.github.com wrote:
Are those builds final yet?
Reply to this email directly or view it on GitHub:
#17 (comment)