Kodi Community Forum

Full Version: JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
sling100 Wrote:Forgive me for the stupid question, but can someone explain to me how I load a .m3u list via JSON? I assume I use a Playlist.GetItems, I'm just not sure of the syntax for using a filename rather than a numerical ID.
As I don't have any .m3u playlist files I never tried this myself but calling Player.Open should be able to handle playlist files (i.e. start playing them) when you provide the path to the .m3u file in the "file" property of the "item" parameter i.e.

Code:
{ "jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "file": "/path/to/your/playlist.m3u" } }, "id": 1 }

Playlist.GetItems can only be used to retrieve the items in a playlist that has already been loaded. Currently it isn't possible to load and manipulate playlist files (like m3u) but we are planning to support this in the future.

jasonvp Wrote:Sorry about that, missed that one.
No problem.
Hi guys,

When using "Playlist.GetItems" to fetch "lyrics" for a song nothing is returned. Is "lyrics" only for karaoke or is it suppose to get lyrics from the lyric Add-on/scrapper (CU Lyrics)?

Is this a Bug?

Also "albumid" and "artistid" is not working in "Playlist.GetItems". Always returns -1 for both.

Cheers
Jason
jasonvp Wrote:Hi guys,

When using "Playlist.GetItems" to fetch "lyrics" for a song nothing is returned. Is "lyrics" only for karaoke or is it suppose to get lyrics from the lyric Add-on/scrapper (CU Lyrics)?

Is this a Bug?
Nah that's not a bug. It only shows lyrics loaded from ID3 tags AFAIK. Imagine it would retrieve the lyrics for every song using an addon. That would take ages if you have a few songs to retrieve.

jasonvp Wrote:Also "albumid" and "artistid" is not working in "Playlist.GetItems". Always returns -1 for both.
That sounds like a bug.
Montellese Wrote:Nah that's not a bug. It only shows lyrics loaded from ID3 tags AFAIK. Imagine it would retrieve the lyrics for every song using an addon. That would take ages if you have a few songs to retrieve.

You can only get the lyrics from Cu Lyrics for the current song anyway from what I can tell.

Would it be possible to retrieve lyrics from the Cu Lyrics just for the currently playing song or do you think it would still take to long?

Quote:That sounds like a bug.

Will I create a ticket or are you onto it?


Cheers
Jason
Hi, I'm trying to use the Player.Shuffle JSON command but it's being a little hairy. I've got it to work once or twice, but right now it's not having any effect. I'm using the latest nightly build.

Sorry for the ambiguity; I guess my question is, are there any known problems with the command? If not I will try to debug this some more.

Here is my c# debug output:
Calling JSON RPC method "Player.Shuffle"...
JSON RPC call: {
"jsonrpc": "2.0",
"method": "Player.Shuffle",
"params": {
"playerid": 0
},
"id": 5
}
JSON RPC response: {"id":5,"jsonrpc":"2.0","result":"OK"}

EDIT: I found the PlayerControl() function online. Interestingly, using the deprecated HTTP API, PlayerControl(Random,true) Works

However, in conjunction with JSON XBMC.Open(), it only worked after adding Thread.Sleep(10000) calls in between XBMC.Open and HTTP-API PlayerControl(Repeat, true) calls
jasonvp Wrote:Would it be possible to retrieve lyrics from the Cu Lyrics just for the currently playing song or do you think it would still take to long?
The native jsonrpc API provided with XBMC will never support addon specific methods because it is not guaranteed that everyone has said addon installed and we can't control which version is installed.

BUT we have already discussed the plan to provide addon developers with the possibility to provide their own jsonrpc methods which can then be used by third party developers if needed.

jasonvp Wrote:Will I create a ticket or are you onto it?
Yes you will Wink It's just easier to keep track of bugs/problems and makes sure I don't forget about them. Most of the time I can fix small bugs within a few hours or a day or two but sometimes I just don't have the time and if there's no ticket I'm bound to forget about it.
aip1000 Wrote:Hi, I'm trying to use the Player.Shuffle JSON command but it's being a little hairy. I've got it to work once or twice, but right now it's not having any effect. I'm using the latest nightly build.

Sorry for the ambiguity; I guess my question is, are there any known problems with the command? If not I will try to debug this some more.

Here is my c# debug output:
Calling JSON RPC method "Player.Shuffle"...
JSON RPC call: {
"jsonrpc": "2.0",
"method": "Player.Shuffle",
"params": {
"playerid": 0
},
"id": 5
}
JSON RPC response: {"id":5,"jsonrpc":"2.0","result":"OK"}
What exactly did you try to do. Just to make sure: Calling Player.Shuffle twice will not reshuffle IIRC because that's how it works in XBMC itself. Back when I implemented the functionality I tested it on all playlist types and it worked but it's always possible to miss a (special) case.

aip1000 Wrote:EDIT: I found the PlayerControl() function online. Interestingly, using the deprecated HTTP API, PlayerControl(Random,true) Works

However, in conjunction with JSON XBMC.Open(), it only worked after adding Thread.Sleep(10000) calls in between XBMC.Open and HTTP-API PlayerControl(Repeat, true) calls
I guess you mean Player.Open() right? There is no XBMC.Open() and you probably also mean PlayerControl(Random, true) and not PlayerControl(Repeat, true)? It might be possible that XBMC hasn't finished adding all the items to the playlist created with Player.Open() when you already try to call Player.Shuffle so the shuffle won't work but that's just a guess.
jasonvp Wrote:Also "albumid" and "artistid" is not working in "Playlist.GetItems". Always returns -1 for both.

OK I just fixed this so it should be available and working correctly in the next nightly build.
Montellese Wrote:OK I just fixed this so it should be available and working correctly in the next nightly build.

Your the Man!

Can you please give me an example for "Player.Seek" params (percentage)? It's driving me nuts. Huh


Cheers
Jason
jasonvp Wrote:Can you please give me an example for "Player.Seek" params (percentage)? It's driving me nuts. Huh

Player.Seek is the best example/usage of the newly supported "union type definition". Player.Seek takes two parameters. The "playerid" (as all the other Player methods do) and a "value" parameter. The "value" parameter can have the following values:
  • a number value between 0.0 and 100.0 in which case it is handled as a percentage value to which the player should seek to. So if you pass 50.0 as the value the player will seek to the middle of the file being played.
  • a string value which takes one of the following values: "smallforward", "smallbackward", "bigforward", "bigbackward". These values replace the old FooPlayer.Small/BigSkipForward/Backward methods that aren't available anymore.
  • an object containg at least one of the following properties: "hours", "minutes", "seconds", "milliseconds". This allows to define a specific time value to which the player will seek to.

Hope this helps.
Montellese Wrote:Player.Seek is the best example/usage of the newly supported "union type definition". Player.Seek takes two parameters. The "playerid" (as all the other Player methods do) and a "value" parameter. The "value" parameter can have the following values:
  • a number value between 0.0 and 100.0 in which case it is handled as a percentage value to which the player should seek to. So if you pass 50.0 as the value the player will seek to the middle of the file being played.
  • a string value which takes one of the following values: "smallforward", "smallbackward", "bigforward", "bigbackward". These values replace the old FooPlayer.Small/BigSkipForward/Backward methods that aren't available anymore.
  • an object containg at least one of the following properties: "hours", "minutes", "seconds", "milliseconds". This allows to define a specific time value to which the player will seek to.

Hope this helps.

Thanks for your explanation.

I didn't put the .0 on the end...Doh!

Code:
{"jsonrpc":"2.0","id":1,"method":"Player.Seek","params":{"playerid":1,"value":50.0}}


Cheers
Jason
jasonvp Wrote:Thanks for your explanation.

I didn't put the .0 on the end...Doh!

Code:
{"jsonrpc":"2.0","id":1,"method":"Player.Seek","params":{"playerid":1,"value":50.0}}


Cheers
Jason

Hm it should work without tha ".0" at the end. I'll reproduce and if it doesn't work, that's a bug.

EDIT: Yeah it's bugged. Sorry for that. Will fix ASAP.
Montellese Wrote:Hm it should work without tha ".0" at the end. I'll reproduce and if it doesn't work, that's a bug.

EDIT: Yeah it's bugged. Sorry for that. Will fix ASAP.

Thanks. It's good to hear I haven't totally lost the plot yet.Eek

jasonvp Wrote:When accessing my Music Videos through "Music/Library/Music Videos" and I use "Player.GetActivePlayers" it returns " "video":true " which is correct but then if I use "VideoPlaylist.GetItems" I don't get any info returned or it returns the last played video from Video Player. I have to use "AudioPlaylist.GetItems" to get any info. This not such a big deal but there is no way to tell that I'm aware of, which Playlist Player is active. Is there a way?


I finally submitted a Ticket #12016 for this.
http://forum.xbmc.org/showthread.php?p=8...post888971

Cheers
Jason
[quote=jasonvp]Thanks. It's good to hear I haven't totally lost the plot yet.Eek[Q/UOTE]
Hehe and I just fixed the bug so a "value" of 50 should now work as well.
jasonvp Wrote:I finally submitted a Ticket #12016 for this.
http://forum.xbmc.org/showthread.php?p=8...post888971

Hi Montellese,

Sorry about all the duplicates.