JSON-RPC Types & Methods
#1
Question 
Hi all

I'm writing a java/android library for XBMC.
I'm trying to generate the methods and classes from the JSON-RPC spec.

I see that JSONRPC.Introspect might do what I want, but it seems it only shows the methods, but not the parameters and the referenced types. Am I wrong?
Can anyone show me how to make json-request to make introspect() output method and type definition (or any other way to get them)?

I see on github there is types.json in the master but not for Dharma.

It seems that there is a difference between the two:
In the github-types.json, Audio.Fields.Album has
Code:
"title", "description", "artist", "genre",
                "theme", "mood", "style", "type", "albumlabel",
                "rating", "year", "musicbrainzalbumid",
                "musicbrainzalbumartistid", "fanart", "thumbnail",
                "artistid"
as fields. But when I look at the request the web interface makes, I see:
Code:
[
      "album_description",
      "album_theme",
      "album_mood",
      "album_style",
      "album_type",
      "album_label",
      "album_artist",
      "album_genre",
      "album_rating",
      "album_title"
    ]
(note the album_ prefix)

Thanks
Reply
#2
Yeah almost everything has changed in JSON-RPC since Dharma has been released. In Dharma there was only a half-baked documentation available through JSONRPC.Introspect and after Dharma it returns a full JSON Schema describing all methods, their parameters and what they return in full detail.

If you are just starting with your library don't even bother with supporting Dharma and start with what is available in the latest nightly builds.

On the wiki you can find an overview over the methods and parameters available in the latest nightly builds but JSONRPC.Introspect is the best way to get a complete documentation.
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
#3
Ah I see, thanks.

I see the next XBMC release is due in a few weeks, so I guess supporting Dharma is indeed a bit pointless.

I built my parser so that it creates Java Classes/Methods from the types.json and methods.json files that I found in github. How are these files generated? Or are they written by hand?

I will check and see if my code can handle the introspect() output of the current nightly build.

Thanks for your help and greetings from Winterthur, CH :-)
Reply
#4
Philz Wrote:Ah I see, thanks.

I see the next XBMC release is due in a few weeks, so I guess supporting Dharma is indeed a bit pointless.
Yup

Philz Wrote:I built my parser so that it creates Java Classes/Methods from the types.json and methods.json files that I found in github. How are these files generated? Or are they written by hand?
Nice idea. Yeah those files are written by hand and then I use a custom script that transforms methods.json, types.json and notifications.json into ServiceDescription.h. Ideally this will be done automatically upon building xbmc but that doesn't work yet and doesn't concern you anyway.

Philz Wrote:I will check and see if my code can handle the introspect() output of the current nightly build.
The output of introspect is almost the same as what is written in the *.json files in xbmc source it is just presented in a global json object containing "methods", "types" and "notifications" properties. Being able to automatically generate your classes based on JSONRPC.Introspect would allow huge flexibility but it might also make it hard to track down certain bugs when something small changes.

Philz Wrote:Thanks for your help and greetings from Winterthur, CH :-)
I'm in Winterthur at least twice a week as I'm studying at the ZHAW Wink
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
#5
Quote:I'm in Winterthur at least twice a week as I'm studying at the ZHAW Wink
What small world: ZHAW? Been there, finished this year (Bsc).

Maybe we should grab a beer sometime.

Anyways, I've let my CodeGen tool run against the current JSON Service Def and it did not generate completely valid code.. yet. 80% of it is valid though.

I will fine tune my code and make some handy addtions. I'll post as soon as I have more on this.

Cheers
Reply
#6
Philz Wrote:What small world: ZHAW? Been there, finished this year (Bsc).

It's even smaller, I finished my Bsc (Systeminformatik) this year as well and have started my master studies in september.
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
#7
Heja - me again,

I finally got some time for my java lib which now allows me to do things like this:
Code:
Playlist playlist = c.openProxy("Playlist", Playlist.class);
PlaylistGetPlaylistsReturnType lists = playlist.GetPlaylists();
System.out.println(lists.PlaylistGetPlaylistsReturnTypeValue[0].type.PlaylistTypeValue);
Which then prints out "audio" for example.

Anyway, my question is: Is there any way to start a audio playlist via JSON-RPC?

The old HTTP-API allowed it and the old remote app for android used it..

Thanks
Reply
#8
You can use the Playlist.Add/Insert methods to put together a playlist and then start it by calling Player.Open and passing the ID of the playlist (0 for audio) in the "playlistid" property of the "item" parameter.
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
#9
Oh bummer :-(

Thanks for the quick answer btw..

The thing is: I'd like to use a tablet or my android phone to start music when I get home. And my audio collection is sorted by genre (via path, not ID3-Tag), so I setup multiple playlists for that. So I just want to hit "Rock" and hear some random rock music from my library.

Do you have a hint or an idea how I could accomplish this?
Reply
#10
Sure you can get the "genreid" with AudioLibrary.GetGenres and then use the "genreid" property in the "item" parameter of Player.Open

EDIT: Sorry didn't see the "by path not by ID3" comment. You can try Playlist.Add with the "directory" property of the "item" parameter to pass the path to one of your genre-sorted directory.
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
#11
Ah I see, yeah that might work and should be fast enough I hope. I'll try this..

Do you have plans to add direct playlist control to the API? I think the XBMC-playlists are quite powerful and handy if you could use them directly via iOS or Android tablets..

I plan to hang a tablet next to entrance door of my appartment, so that when I get home, with a push of a button can start some music without fiddling to much with remotes etc.. (or powering up the tv etc.)

Since you're in the area, I could give you a demo sometime :-)
Reply
#12
Yeah extending the playlist functionality is planned but (not counting Smart Playlists) playlist handling is a bit limited in XBMC and difficult to expose to the outside world. I/we/someone first has to make that part of the code more flexibal and more "universal" to be able to provide a powerful playlist API to clients.

What features are you missing? Do you have any examples of what you especially would like to see?
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
#13
For me, all I need is a function to get the names of the pre-defined playlists and a function to make it play.

My playlists are like "Rock": "if path contains 'rock'" add it to the list. etc. Nothing fancy with year tags etc. Empty ID3 tags are still very common.

I think a lot of people just have an assortment of music and just want to listen to a certain style or maybe artist and then hit shuffle. In my 11 years of ownership of portable mp3 players, 90% of the time I just want it to shuffle. It all comes down to "Don't make me think" (good book btw).
Reply
#14
Support for getting all pre-defined playlists (video and music) and loading them into a playable playlist will be added after Eden.
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
#15
Awesome! Is there anything I can help with?
I'm not a pro-C++ coder (I do code java for a living though), but I can make it work. I might help testing or something..
Reply

Logout Mark Read Team Forum Stats Members Help
JSON-RPC Types & Methods0