Search code examples
jsonjson-rpcxbmc

How to get currently playing item in XBMC?


I want to use json/rpc in order to get the currently playing item in the XBMC, I'm using the following commands for all the of player types:

  • to getting the Active player :

    { "jsonrpc": "2.0", "method": "Player.GetActivePlayers", "id": 1 }

  • And to getting the currently playing item due to the above result:

    { "jsonrpc": "2.0", "method": "Playlist.GetItems", "params": { "playlistid": playlist.id, "properties": ["title", "rating", "season", "episode", "plot", "runtime", "showtitle", "thumbnail", "year", "genre"] }, "id": 1 }

Now, I have three different cases:

1- if the currently playing item is a "movie": every thing works very efficient.

2- if the currently playing item is a "song": the result set contains not only the currently playing song but all the songs of the album that contains the currently playing song.

3- if the currently playing item is a "tvShow episode": the result set is empty like if there is nothing currently playing.


Solution

  • This should do it:

    {
        "jsonrpc": "2.0",
        "method": "Player.GetItem",
        "params": {
            "properties": [
                "title",
                "album",
                "artist",
                "season",
                "episode",
                "duration",
                "showtitle",
                "tvshowid",
                "thumbnail",
                "file",
                "fanart",
                "streamdetails"
            ],
            "playerid": 1
        },
        "id": "VideoGetItem"
    }
    

    Check this out for further API examples.