Help getting player state
#1
Wow - and I thought MAPI was tricky. :-p

So, this is the deprecated one-liner for getting the player state:
http://192.168.0.1:8080/xbmcCmds/xbmcHtt...tlyplaying

In JSON RPC, I think that I first have to enumerate all the players. I think. But then what? I can stop, start, pause, but how do I say "what is happening now?"?
What I am finding immensely frustration, is that whilst the methods are published, there's no explanation of why I need to do stuff, so for example I am struggling to see why I need to enumerate players, or even what that means.

So, my question is, am I missing a wiki page that I haven't found?
http://wiki.xbmc.org/index.php?title=JSON-RPC_API/v4
http://forum.xbmc.org/showthread.php?tid=98551

Failing that, how much long will the simpler xbmcCmds be around for?
Reply
#2
OK, getting somewhere:
'{ "jsonrpc": "2.0", "method": "Player.GetProperties", "params": { "playerid": 0, "properties": ["speed"] }, "id": 1 }'

Now, what about the playerid? I click on that in the API and it says "Type: integer". Hmmm, OK, so at least I know not to try player.id 1.5, or Pi. Wink
What actually does playerid represent and how do I retrieve it's value? Player.GetActivePlayers sounds like it might be the thing? Nothing in the API documentation that relates Player.GetActivePlayers to playerid. It does tell me that it Returns: Type: array. An array of what? ActivePlayers one would assume, but what is the data type of an ActivePlayers.

I shall carry on guessing until something works...
Reply
#3
Player.GetActivePlayers to get the player id
Request:
Code:
{
    'jsonrpc': '2.0',
    'id': 0,
    'method': 'Player.GetActivePlayers',
    'params': {},
}

Result:
Code:
{
    "jsonrpc": "2.0",
    "id": 0,
    "result": [
        {
            "playerid": 1,
            "type": "video"
        }
    ]
}

Player.GetItem to know what the player is playing

Request:
Code:
{
    'jsonrpc': '2.0',
    'id': 0,
    'method': 'Player.GetItem',
    'params': {'playerid': 1, 'properties': ['thumbnail']},
}

Result:
Code:
{
    "jsonrpc": "2.0",
    "id": 0,
    "result": {
        "item": {
            "type": "unknown",
            "thumbnail": "image://video@smb%3a%2f%2funraid%2fMUSIC%2fMachine%20Head%20-%20Darkness%20Within.mp4/",
            "label": "Machine Head - Darkness Within.mp4"
        }
    }
}

Once you figure out how the wiki/introspect works it becomes much easier Smile

EDIT: Player IDs are 0=music, 1=video, 2=pictures
Image
Reply
#4
Thank you very much. What I could not see is where it says that Player.GetActivePlayers returns the PlayerID. I guess I should still consider it very much a work in progress.
Reply
#5
The presentation of the documentation on the wiki sucks but I don't have time to write (and especially keep up-to-date) the documentation manually for the whole API so I have written a very simple python script which generates what you see in the wiki. If you think there's not enough information you should always expand the "JSON Schema Description" (gray box) by clicking on the respective "show" link. That will give you the real JSON schema for the method you are looking at which contains all the information you need to know. In the case of Player.GetActivePlayers that will give you
Code:
{
  "params": [],
  "description": "Returns all active players",
  "returns": {
    "uniqueItems": true,
    "items": {
      "properties": {
        "type": {
          "$ref": "Player.Type",
          "required": true
        },
        "playerid": {
          "$ref": "Player.Id",
          "required": true
        }
      },
      "type": "object"
    },
    "type": "array"
  }
}
where you can see the "playerid" and the "type" properties which every item in the returned array provides.

PS: Currently playerids are 0=music, 1=video, 2=pictures but that might change in the future. The reason behind having Player.GetActivePlayers and having to pass a "playerid" to every Player method is that XBMC can have multiple players active at the same time (right now only slideshow and music) so you have to tell XBMC which player you want to control. HTTP-API wasn't able to do that because it didn't cover slideshows.
Always read the online manual (wiki), FAQ (wiki) and search the forum before posting.
Do not e-mail Team Kodi members directly asking for support. Read/follow the forum rules (wiki).
Please read the pages on troubleshooting (wiki) and bug reporting (wiki) before reporting issues.
Reply
#6
This reminds me. I'll try and get some examples up on the wiki page.
Image
AWXi - Ajax web interface. Wiki
Reply
#7
@Montellese: Much appreciated. I don't like to sound like I'm complaining because I'm not: I know people have worked very hard to produce something that is completely free, so it is really appreciated.

@Mizaki: Yes, that would be really help. Cheers!
Reply
#8
Am I missing something or is there another way to get "Now Playing" info? Because using the above method would miss alot of info.

For example, on the screen when playing a song, in now playing (fullscreen) mode I can see:
_ album cover (i.e. folder.jpg)
_ starttime, endtime of the song
_ song title

However, via JSON RPC, I retrieved all the fields of GetItem() with this specs Fields.All but only the following fields come back as result:
Code:
art: <<blank>>
fanart: <<blank>>
file: smb://MICRSVR/Music/Lossless/Album005/barbiegirl.wav
label: 02 - Barbie Girl Aqua.wav
thumbnail: <<blank>>
title: <<blank>>
type: unknown


Any help is appreciated.
Reply
#9
I'll take a wild guess that the file isn't in the library ("type: unknown"). Therefore, there is no information to return. It's possible in some instances that the GUI has more access to information than the JSONRPC. You say all fields. I don't believe anyone (for good reason as anyone who has worked in IT will know) so make sure to post the exact command you are trying.
Image
AWXi - Ajax web interface. Wiki
Reply

Logout Mark Read Team Forum Stats Members Help
Help getting player state0