Newbie: Play Video from command line/Python/JSON
#1
Hi,

I'm a happy brand new owner of a Raspberry Pi and installed xbmc on it. I've looked into my issue quite a while now, and although I consider myself quite programming/IT-savvy in general, I can't find a working solution to my problem:

I need to play back a video file on the push of a physical button. It's an exhibition setup with a box that has a screen, a button, two headphones. A presentation kiosk. I got the button working fine via GPIO/Python. Now I need to find a way to trigger that video playback, a file located at /media/Transcend/Antithesis.mp4.
Ideally, that file would stop at the last frame so that the xbmc UI is never visible, but that's a secondary problem.

I understand that the Python xbmc library isn't available in the command line, only from within xbmc. But that approach doesn't work for me because it's headless. I've tried adding scripts to autoexec.py, but it didn't work out and since there's no immediate debugging output, this approach is a dead end for me.

Left are the various approaches to remote control xbmc over the network, for instance via JSON. Problem is that I look into JSON like a pig looks into the clockwork (as we say over here).

I've set up a command that looks like this (Safari automatically URL-encodes the strings, so that shouldn't be a problem):
Code:
http://localhost/jsonrpc?request={"jsonrpc": "2.0", "method": "Player.Open", "params": { "item": "/media/Transcend/Antithesis.mp4" }, "id": 1}

Answer:
Code:
{"error":{"code":-32602,"data":{"method":"Player.Open","stack":{"message":"Invalid type string received","name":"item","type":"object"}},"message":"Invalid params."},"id":1,"jsonrpc":"2.0"}

I have no idea how to continue from here.
Can anyone help me with the JSON commands, or, alternatively, find another way to play a video file from a command line level Python script?
Thank you!!!
Reply
#2
I am not much of coder my self so sorry if this is not correct.

if this is intended to call video player
PHP Code:
"id"1

i think id should be 0.

Video player id =0, audio player id = 1, photo player id =2
Reply
#3
Thank you, I tried that with the ID. But no effect.
After having found an example of a JSON call via curl in the command line I'm now 100% certain that the method my call is correct and the problem lies not with URLencoding or content type encoding, as it returned the same response string:
Code:
curl --data-binary '{"jsonrpc": "2.0", "method": "Player.Open", "params": { "item": "/media/Transcend/Antithesis.mp4" }, "id": 1}' -H 'content-type: application/json;' http://192.168.124.33/jsonrpc

My problem must lie with the syntax of the call. Here I have absolutely no experience. I agree with OP of this thread that the documentation is little helpful because there are no examples.
How do I construct my call out of this?:
Reply

Logout Mark Read Team Forum Stats Members Help
Newbie: Play Video from command line/Python/JSON0