Kodi Community Forum
JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Development (https://forum.kodi.tv/forumdisplay.php?fid=32)
+--- Forum: Kodi Application (https://forum.kodi.tv/forumdisplay.php?fid=93)
+---- Forum: JSON-RPC (https://forum.kodi.tv/forumdisplay.php?fid=174)
+---- Thread: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC (/showthread.php?tid=68263)



- bartdesign - 2011-06-12

Thanks Topfs2,

I've created an ticket: http://trac.xbmc.org/ticket/11629
I hope it get's implemented, it makes sense to include references back to the tv show.


- Montellese - 2011-06-12

IMO it's a reasonable request and there are other such ID's which should be exposed. These are the ones I've identified so far:

- "tvshowid" for episodes
- "setid"s for movies in sets
- "genreid"s for movies, tvshows, musicvideos, artists, albums and songs
- "artistid" for albums and songs
- "albumid" for songs

If I missed something, please let me know.


- bartdesign - 2011-06-13

Montellese Wrote:IMO it's a reasonable request and there are other such ID's which should be exposed. These are the ones I've identified so far:

- "tvshowid" for episodes
- "setid"s for movies in sets
- "genreid"s for movies, tvshows, musicvideos, artists, albums and songs
- "artistid" for albums and songs
- "albumid" for songs

If I missed something, please let me know.

Looking good Smile
I've also looked through the introspect again but I can't think of any other ones that need to be included apart from the ones in your post.


- Jason102 - 2011-06-14

Has the functionality of the Files.GetDirectory call changed? I use the call in PseudoTV to get all of the elements in a smart playlist. This no longer works, I only receive an empty list using the daily builds:

Code:
{"id":1,"jsonrpc":"2.0","result":{"files":null,"limits":{"end":0,"start":0,"total":0}}}

Is this expected? Is there some new way to get smart playlist contents?


- Montellese - 2011-06-14

Jason102 Wrote:Has the functionality of the Files.GetDirectory call changed? I use the call in PseudoTV to get all of the elements in a smart playlist. This no longer works, I only receive an empty list using the daily builds:

Code:
{"id":1,"jsonrpc":"2.0","result":{"files":null,"limits":{"end":0,"start":0,"total":0}}}

Is this expected? Is there some new way to get smart playlist contents?

Could you please provide your jsonrpc request? It might be that this broke during my re-write of how metadata for files is handled.


- Jason102 - 2011-06-14

Quote:Could you please provide your jsonrpc request?

Code:
{"jsonrpc": "2.0", "method": "Files.GetDirectory", "params": {"directory": "Smart Playlist Complete Path", "media": "video", "fields":["duration","runtime","tagline","showtitle","album","artist","plot"]}, "id": 1}



- Montellese - 2011-06-14

Jason102 Wrote:Has the functionality of the Files.GetDirectory call changed? I use the call in PseudoTV to get all of the elements in a smart playlist. This no longer works, I only receive an empty list using the daily builds:

Code:
{"id":1,"jsonrpc":"2.0","result":{"files":null,"limits":{"end":0,"start":0,"total":0}}}

Is this expected? Is there some new way to get smart playlist contents?

You were right and I fixed it in this commit. Thanks for the report.


Requesting currently playing audio? - doozer - 2011-06-17

Hi All,

Appologies if this has already been answered, but search wouldn't narrow anything down other than somewhere in these 100+ pages!

I have some of the basic JSON interface working and get an unsolicited notification when a new song starts playing:

Code:
{"jsonrpc":"2.0","method":"Player.OnPlay","params":{"data":{"speed":1,"type":"song"},"sender":"xbmc"}}

Once I receive this i'm able to request the current position and track length, but what i'm struggling with is how to obtain the track title, artist, album and coverart?

If figured "AudioLibrary.GetSongDetails" might help, but it needs a songid that I don't have.

I'm using the bleeding edge build from last night of PRE-11.0.

Thanks,
Matt.


- Montellese - 2011-06-17

Theoretically you should get the songid in the "id" field in the notification. How do you start playback of that song and is that song in your music library? There are a few situations where you won't get the ID of the song because it can't be retrieved but usually you should receive it with the notification.

Another way of obtaining the currently playing song is to call AudioPlaylist.GetItems which contains a list of all songs that are in the current playlist. Furthermore there is a value called "current" which returns the index of the currently playing song which you can use to access the song from the list of songs in the current playlist.

EDIT: Here's an example of what I get when I start playback of a song through the XBMC user interface:
Code:
{ "jsonrpc": "2.0", "method": "Player.OnPlay", "params": { "data": { "id": 869, "speed": 1, "type": "song" }, "sender": "xbmc" }}



- doozer - 2011-06-17

I am using my mouse directly on the XBMC PC to start the song playing.
Should I be getting a songid in that case?

Thanks for the quick reply. I'll give the GetItems a go.

Montellese Wrote:Theoretically you should get the songid in the "id" field in the notification. How do you start playback of that song and is that song in your music library? There are a few situations where you won't get the ID of the song because it can't be retrieved but usually you should receive it with the notification.

Another way of obtaining the currently playing song is to call AudioPlaylist.GetItems which contains a list of all songs that are in the current playlist. Furthermore there is a value called "current" which returns the index of the currently playing song which you can use to access the song from the list of songs in the current playlist.

EDIT: Here's an example of what I get when I start playback of a song through the XBMC user interface:
Code:
{ "jsonrpc": "2.0", "method": "Player.OnPlay", "params": { "data": { "id": 869, "speed": 1, "type": "song" }, "sender": "xbmc" }}



- Montellese - 2011-06-17

doozer Wrote:I am using my mouse directly on the XBMC PC to start the song playing.
Should I be getting a songid in that case?

Thanks for the quick reply. I'll give the GetItems a go.

The only way I can think of right now which won't give you the songid is if you start the song from RecentlyAdded on your home screen or if it is not part of your library. But IIRC in both those cases you should get "type": "unknown" and not "type": "song". I'll have to try later if I can reproduce such a problem.

Are you starting playback of a whole album/artist or a single song?


- Montellese - 2011-06-17

The only way I could reproduce your notification without the "id" field is by starting playback of a song through a plugin like Last.FM which obviously plays songs which are not in the database.

Starting playback of a whole album or artist returns no "id" and "type": "unknown" (I'll see if I can at least return "type": "song" for these though).


- doozer - 2011-06-17

I added a network folder (SMB) that has about half a dozen albums in it.

From the home menu I selected "Music".
Browsed into the 2nd album in the list.
Single clicked track 3.

This played track 3 and then the rest of the album. During my JSON testing I was mostly hitting pause on the current song then play (to continue the song) which would trigger the OnPlay notification.

No black magic involved Smile

Montellese Wrote:The only way I can think of right now which won't give you the songid is if you start the song from RecentlyAdded on your home screen or if it is not part of your library. But IIRC in both those cases you should get "type": "unknown" and not "type": "song". I'll have to try later if I can reproduce such a problem.

Are you starting playback of a whole album/artist or a single song?



- doozer - 2011-06-17

Nope not using any Internet based services - the mp3's are on my LAN.

I get the same OnPlay notification if I navigate and start the song via Input.Select.

Do I need to change any settings via JSONRPC.SetNotificationFlags?

Montellese Wrote:The only way I could reproduce your notification without the "id" field is by starting playback of a song through a plugin like Last.FM which obviously plays songs which are not in the database.

Starting playback of a whole album or artist returns no "id" and "type": "unknown" (I'll see if I can at least return "type": "song" for these though).



- doozer - 2011-06-17

Using AudioPlaylist.GetItems seems to only give you the filename (or label) as XBMC calls it of the songs.

Is there a way to obtain the full info: Artist, Album, Coverart, Song name etc?

Thanks,
Matt.