Player.Open
#1
I am using jsonrpclib which I patched to give the correct UI. I can use it great for reading information getting lists of files and other read only actions. However I cannot figure out the enigma that is Player.open() I have tried about twenty different ways to pass a file name or episode ID to that function so that it starts to play the given file. However regardless of what I attempt I always get jsonrpclib.jsonrpc.ProtocolError: (-32602, u'Invalid params.') http://wiki.xbmc.org/index.php?title=JSO...layer.Open is utterly useless as there are no examples.
right now I use:
server.VideoLibrary.GetEpisodes(x['tvshowid'],<SEASON_NUMBER>,[LIST OF FIELDS I WANT RETURNED])
for working with episodes and its flawless but for some reason I cannot get the play to work.
Reply
#2
mcstubb,

Below are some params examples you can use. I totally agree that the documentation (and interfaces themselves) for json-rpc and python could use tremendous improvement. The following python def gives you some examples of how to format a variety of Player.Open requests.

Code:
def xbmc_player_open():
    
    data = {"jsonrpc": "2.0",
        "id": 1,
        "method": "Player.Open",
        "params": {"item": {"directory":"/path/to/my/directory"},
                "options": {"repeat": "all",
                    "shuffled": True
                }
                },
    }
    
    #playing single file
    #"params": {"item": {"file":"/home/pi/images/my_file.MOV"}
    
    
    #Starting specific playlist. Range is -1 to 2. 1 is video, 2 is picture.
    """
        "params": {"item": {"playlistid": 1,
        "position": 0
        },
        "options": {"repeat": "all",
        "shuffled": True
        }
        },
        """
    
    data_as_json = json.dumps(data)
    print 'play_xbmc_directory'
    print data_as_json
    
    req = urllib2.Request('http://127.0.0.1:8080/jsonrpc', data_as_json, {'Content-Type': 'application/json'})
    
    response = urllib2.urlopen(req)
    result = json.loads(response.read())
    #switch back to json with pretty format
    print json.dumps(result, indent=4)
    
    return result
Reply
#3
I know it was months ago but THIS rescued me from 30 minutes of trying to figure out the inscrutable fucking json schema.

Would it kill the dev's to put a freaking example in the instrospection return?

Thank you for this!!!
Reply
#4
Nick,

Chill out. We've seen your rants in other posts. No one's impressed.

As for examples, there's this thread from March which had several examples of the "Player.Open" method in it.

The JSON wiki page is also excellent at showing what parameters can/must be passed in JSON requests.

I've also found that whatever I've needed to do via JSON is already in the forums or, if not, I can ask (politely) in the JSON sub-forum and someone's there to help out.

Continuous ranting will not encourage people to help you.


I also replied to your "HEEEEELLLLLP MEEHHHHHH please?!" in a separate thread almost a week ago yet you've not bothered to follow up my question.
BBC Live Football Scores: Football scores notifications service.
script.squeezeinfo: shows what's playing on your Logitech Media Server
Reply

Logout Mark Read Team Forum Stats Members Help
Player.Open0