Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with start position / seeking #17

Open
drdaz opened this issue Jun 12, 2011 · 5 comments
Open

Issues with start position / seeking #17

drdaz opened this issue Jun 12, 2011 · 5 comments

Comments

@drdaz
Copy link

drdaz commented Jun 12, 2011

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

@drdaz
Copy link
Author

drdaz commented Jun 12, 2011

If I'm not mistaken this issue has to do with this (now fixed) issue in XBMC:

http://trac.xbmc.org/ticket/10095

@drdaz drdaz closed this as completed Jun 12, 2011
@drdaz drdaz reopened this Jun 12, 2011
@drdaz
Copy link
Author

drdaz commented Jun 12, 2011

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.

@drdaz
Copy link
Author

drdaz commented Jun 12, 2011

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

@pascalw
Copy link
Owner

pascalw commented Jun 18, 2011

Are those builds final yet?

@drdaz
Copy link
Author

drdaz commented Jun 19, 2011

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, [email protected] wrote:

Are those builds final yet?

Reply to this email directly or view it on GitHub:
#17 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants