JSON-RPC (JSON Remote Procedure Call) interface protocol in development for XBMC

  Thread Rating:
  • 8 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
Fuzzwah Offline
Junior Member
Posts: 8
Joined: Jun 2013
Reputation: 0
Post: #2896
Awesome, thanks guys. Will give this a shot when I'm back at home.
find quote
Fuzzwah Offline
Junior Member
Posts: 8
Joined: Jun 2013
Reputation: 0
Post: #2897
Alas, no joy.

I'm able to add items to a playlist using:

Code:
curl -v -H 'Accept: application/json' -H 'Content-type: application/json' -X POST -d '{"jsonrpc":"2.0","method":"Playlist.Add","params":{"playlistid":0,"item":{"directory":"special://profile/playlists/music/NiN.m3u"}},"id":1}' http://192.168.0.16:8080/jsonrpc

Which I can confirm using GetItems:

Code:
{"id":1,"jsonrpc":"2.0","result":{"items":[{"id":6324,"label":"04 - Sanctified.mp3","type":"song"},{"id":6325,"label":"05 - Something I Can Never Have.mp3","type":"song"},{"id":6386,"label":"12 - The Way Out Is Through.mp3","type":"song"},{"label":"Nine_Inch_Nails_-_piggy.mp3","type":"unknown"},{"id":6270,"label":"Nine Inch Nails - 15 - In This Twilight.mp3","type":"song"},{"id":6261,"label":"Nine Inch Nails - 06 - Me I'm Not.mp3","type":"song"},{"id":6391,"label":"05 - Please.mp3","type":"song"},{"label":"Nine_Inch_Nails_-_big_man_with_a_gun.mp3","type":"unknown"},{"label":"Nine_Inch_Nails_-_heresy.mp3","type":"unknown"},{"id":6393,"label":"07 - Complication.mp3","type":"song"},{"id":6380,"label":"06 - The Fragile.mp3","type":"song"},{"id":6397,"label":"11 - Ripe (With Decay).mp3","type":"song"},{"id":6381,"label":"07 - Just Like You Imagined.mp3","type":"song"},{"id":6378,"label":"04 - The Wretched.mp3","type":"song"},{"id":6263,"label":"Nine Inch Nails - 08 - My Violent Heart.mp3","type":"song"},{"id":6383,"label":"09 - Pilgramige.mp3","type":"song"},{"id":6394,"label":"08 - I'm Looking Forward To Joining You, Finally.mp3","type":"song"},{"id":6268,"label":"Nine Inch Nails - 13 - The Great Destroyer.mp3","type":"song"},{"id":6385,"label":"11 - La Mer.mp3","type":"song"},{"id":6379,"label":"05 - We're In This Together.mp3","type":"song"},{"id":6389,"label":"03 - Where Is Everybody_.mp3","type":"song"},{"id":6328,"label":"08 - That's What I Get.mp3","type":"song"},{"id":6326,"label":"06 - Kinda I Want To.mp3","type":"song"},{"id":6259,"label":"Nine Inch Nails - 04 - The Good Soldier.mp3","type":"song"},{"id":6395,"label":"09 - The Big Come Down.mp3","type":"song"},{"id":6329,"label":"09 - The Only Time.mp3","type":"song"},{"id":6377,"label":"03 - The Frail.mp3","type":"song"},{"id":6265,"label":"Nine Inch Nails - 10 - God Given.mp3","type":"song"},{"id":6264,"label":"Nine Inch Nails - 09 - The Warning.mp3","type":"song"},{"label":"Nine_Inch_Nails_-_march_of_the_pigs.mp3","type":"unknown"},{"id":6387,"label":"01 - The Way Out Is Through.mp3","type":"song"},{"id":6269,"label":"Nine Inch Nails - 14 - Another Version Of The Truth.mp3","type":"song"},{"id":6260,"label":"Nine Inch Nails - 05 - Vessel.mp3","type":"song"},{"id":6258,"label":"Nine Inch Nails - 03 - Survivalism.mp3","type":"song"},{"id":6375,"label":"01 - Somewhat Damaged.mp3","type":"song"},{"id":6266,"label":"Nine Inch Nails - 11 - Meet Your Master.mp3","type":"song"},{"id":6267,"label":"Nine Inch Nails - 12 - The Greater Good.mp3","type":"song"},{"id":6256,"label":"Nine Inch Nails - 01 - Hyperpower.mp3","type":"song"},{"id":6382,"label":"08 - Even Deeper.mp3","type":"song"},{"label":"Nine_Inch_Nails_-_closer.mp3","type":"unknown"},{"label":"Nine_Inch_Nails_-_ruiner.mp3","type":"unknown"},{"id":6257,"label":"Nine Inch Nails - 02 - The Beginning Of The End.mp3","type":"song"},{"id":6390,"label":"04 - The Mark Has Been Made.mp3","type":"song"},{"id":6392,"label":"06 - Starfuckers, Inc.mp3","type":"song"},{"id":6388,"label":"02 - Into The Void.mp3","type":"son* Connection #0 to host 192.168.0.16 left intact
g"},{"label":"Nine_Inch_Nails_-_i_do_not_want_this.mp3","type":"unknown"},{"id":6330,"label":"10 - Ringfinger.mp3","type":"song"},{"id":6376,"label":"02 - The Day The World Went Away.mp3","type":"song"},{"id":6322,"label":"02 - Terrible Lie.mp3","type":"song"},{"id":6327,"label":"07 - Sin.mp3","type":"song"},{"id":6321,"label":"01 - Head Like a Hole.mp3","type":"song"},{"id":6323,"label":"03 - Down In It.mp3","type":"song"},{"label":"Nine_Inch_Nails_-_the_becoming.mp3","type":"unknown"},{"label":"Nine_Inch_Nails_-_mr_self_destruct.mp3","type":"unknown"},{"id":6396,"label":"10 - Underneath It All.mp3","type":"song"},{"id":6271,"label":"Nine Inch Nails - 16 - Zero Sum.mp3","type":"song"},{"id":6384,"label":"10 - No, You Don't.mp3","type":"song"},{"id":6262,"label":"Nine Inch Nails - 07 - Capitol G.mp3","type":"song"}],"limits":{"end":58,"start":0,"total":58}}}* Closing connection #0

However, when I then try and send through the shuffle command:

Code:
curl -v -H 'Accept: application/json' -H 'Content-type: application/json' -X POST -d '{"jsonrpc":"2.0","method":"Player.SetShuffle","params":{"playerid": 0, "shuffle": true},"id":1}' http://192.168.0.16:8080/jsonrpc

I get the following message:

Code:
{"error":{"code":-32100,"message":"Failed to execute method."},"id":1,"jsonrpc":"2.0"}* Closing connection #0

Then I just tried to get the damn playlist to play and can't even do that.... fail:

Code:
curl -v -H 'Accept: application/json' -H 'Content-type: application/json' -X POST -d '{"jsonrpc":"2.0","method":"Player.PlayPause","params":{"playerid": 0, "play": true},"id":1}' http://192.168.0.16:8080/jsonrpc

Result:

Code:
{"error":{"code":-32100,"message":"Failed to execute method."},"id":1,"jsonrpc":"2.0"}* Closing connection #0

Any help is truly appreciated, starting to get a little frustrated at my failure to do something which seems pretty simple.
find quote
Tolriq Offline
Donor
Posts: 2,185
Joined: Jun 2009
Reputation: 67
Location: France
Post: #2898
Welcome to Xbmc in all it's beauty Smile

All your queries fails because no player are yet started.

Once files are in playlist you need to Player.Open to start the player then you can shuffle and play/pause things.

To simulate random also on first song just start the player.open with a random position in the playlist and not 0 Smile

Yatse 2 : Media Center Remote Control for Touch Screens
Yatse, the Xbmc Remote and Widgets for Android
find quote
Kabooga Offline
Senior Member
Posts: 225
Joined: Feb 2009
Reputation: 1
Location: Silicon Valley, CA
Post: #2899
Good point Tolriq. I should have mentioned that.

Had to laugh at this one.
Quote:Welcome to Xbmc in all it's beauty

I am an expert at acting like an expert ---- WC Fields.

XBMC Web Control Interface - https://github.com/mthiels/webinterface.xrc
find quote
Fuzzwah Offline
Junior Member
Posts: 8
Joined: Jun 2013
Reputation: 0
Post: #2900
Awesome, I finally have my script set up which will kick off playback of a shuffled playlist....... but I have a bug. The volume seems to change somewhat randomly.

My script clears the playlist (if any), sets the volume to 11, builds the playlist, player.open's the playlist and then shuffles the playlist.

Code:
#!/bin/bash

echo "Triggering playback of $1"

curl -v -H 'Accept: application/json' -H 'Content-type: application/json' -X POST -d '{"jsonrpc":"2.0","method":"Playlist.Clear","params":{"playlistid": 0},"id":1}' http://192.168.0.16:8080/jsonrpc

curl -H 'Accept: application/json' -H 'Content-type: application/json' -X POST -d '{"jsonrpc": "2.0", "method": "Application.SetVolume", "params": {"volume": 11}, "id": 1}' http://192.168.0.16:8080/jsonrpc

curl -H "Accept: application/json" -H "Content-type: application/json" -X POST -d "{\"jsonrpc\":\"2.0\",\"method\":\"Playlist.Add\",\"params\":{\"playlistid\":0,\"item\":{\"directory\":\"special://profile/playlists/music/$1.m3u\"}},\"id\":1}" http://192.168.0.16:8080/jsonrpc

curl -H 'Accept: application/json' -H 'Content-type: application/json' -X POST -d '{"jsonrpc":"2.0","method":"Player.Open","params":{"item": {"playlistid": 0}},"id":1}' http://192.168.0.16:8080/jsonrpc

curl -H 'Accept: application/json' -H 'Content-type: application/json' -X POST -d '{"jsonrpc": "2.0", "method": "Player.SetShuffle", "params": {"playerid": 0, "shuffle": true }, "id": 1}' http://192.168.0.16:8080/jsonrpc

But yeah, occasionally when a new track starts playing the volume will get set up to something like 50..... totally ear smashingly loud. Weird.

Any clue as to what is happening?
find quote
claymic Offline
Senior Member
Posts: 111
Joined: Apr 2012
Reputation: 2
Post: #2901
Hi
A simple question. How i can see a image from the xmbc in my browser ? I tried in two ways.
Quote:http://xmbc@myip:8080/image/image://Q%3a%5cMovies3tb2%5cFilmesHD3tb2%5cThe%20Ledge%20(2011)%5cThe%20Ledge%20(2011).b​luray.tbn/
The other way i am using in my ipad app and works in the Ipad, but dont work in another app that i am creating
Quote:http://xmbc@myip:8080/vfs/image://Q%3a%5cMovies3tb2%5cFilmesHD3tb2%5cThe%20Ledge%20(2011)%5cThe%20Ledge%20(2011).b​luray.tbn/
Thanks for the help guys.
Clayton
(This post was last modified: 2013-07-02 23:03 by claymic.)
find quote
claymic Offline
Senior Member
Posts: 111
Joined: Apr 2012
Reputation: 2
Post: #2902
Sorry guys, my bad, i forgot to encode the "image://".
Next question. There is any difference between the thumbnail path that we get from Frodo and Gotham ? Its the same ?
Thanks
Clayton
(This post was last modified: 2013-07-03 16:54 by claymic.)
find quote
jon889 Offline
Junior Member
Posts: 3
Joined: Jul 2013
Reputation: 0
Post: #2903
I'm trying to get the thumbnail for addons. the Addons.GetAddons returns exactly this: "image://%2fhome%2fxbian%2f.xbmc%2faddons%2fplugin.video.1channel%2ficon.png"

So I thought I could just do: http://192.168.2.12:8080/image/image://%...2ficon.png

but I get no response, and the wiki says I have encode the image://...

so this results in the path being double encoded:
http://192.168.2.12:8080/image/image%3a%...2ficon.png

Is this really right?

Also it's strange
This returns a jpg:
http://192.168.2.12:8080/image/image%3a%...2ficon.png

as does this:
http://192.168.2.12:8080/image/image://%...2ficon.png

and this returns a png:
http://192.168.2.12:8080/image/image://%...2ficon.png

(note how the slash before home is not double encoded)

this gives no response:
http://192.168.2.12:8080/image/image://%...2ficon.png

(note how the slash before and after home is not double encoded)

this all seems illogical, so could someone clarify it?
find quote
danmedhurst Offline
Fan
Posts: 384
Joined: Jul 2008
Reputation: 2
Post: #2904
via SSH :

xbmc-send -a ContextMenu

[Image: 993659535.png]
find quote
Tolriq Offline
Donor
Posts: 2,185
Joined: Jun 2009
Reputation: 67
Location: France
Post: #2905
Just noticed a change in last gotham during some tests.

It seems that now neither the title nor the label are filled when playing a random file via JSON.
Before label was filled with the filename (without path) and seems a good thing since the label is a mandatory item.

Edit :

After some debugging I'm lost on what seems multiple strange things, so don't know if they are errors or if normal and so where I should patch.

In CPlayerOperations::GetItem

Code:
else if (player == Video)
      {
        if (!CVideoLibrary::FillFileItem(g_application.CurrentFile(), fileItem, parameterObject))
        {
          const CVideoInfoTag *currentVideoTag = g_infoManager.GetCurrentMovieTag();
          if (currentVideoTag != NULL)
            fileItem = CFileItemPtr(new CFileItem(*currentVideoTag));
          fileItem->SetPath(g_application.CurrentFileItem().GetPath());
        }
      }
      else
      {
        if (!CAudioLibrary::FillFileItem(g_application.CurrentFile(), fileItem, parameterObject))
        {
          const MUSIC_INFO::CMusicInfoTag *currentMusicTag = g_infoManager.GetCurrentSongTag();
          if (currentMusicTag != NULL)
            fileItem = CFileItemPtr(new CFileItem(*currentMusicTag));
          fileItem->SetPath(g_application.CurrentFileItem().GetPath());
        }
      }

When playing a video file the second else block will also be called is this intended ?


In CVideoLibrary::FillFileItem
Code:
CVideoDatabase videodatabase;
  if (strFilename.empty() || !videodatabase.Open())
    return false;

  CVideoInfoTag details;
  if (!videodatabase.LoadVideoInfo(strFilename, details))
    return false;

  item->SetFromVideoInfoTag(details);
  if (item->GetLabel().empty())
    item->SetLabel(CUtil::GetTitleFromPath(strFilename, false));
  if (item->GetLabel())
    item->SetLabel(URIUtils::GetFileName(strFilename));
  return true;

Since the file is started from JSON for first time it's not yet in any database so
Code:
if (!videodatabase.LoadVideoInfo(strFilename, details))
    return false;

Will return false and the label is never set.

Then on the last part I'm not sure to understand, you test if the label is empty then set it, then you set if the label is present and set it again ?

Not sure what part should be patched and with what Smile So waiting for more details

Yatse 2 : Media Center Remote Control for Touch Screens
Yatse, the Xbmc Remote and Widgets for Android
(This post was last modified: 2013-07-15 12:44 by Tolriq.)
find quote
Montellese Online
Team-XBMC Developer
Posts: 3,477
Joined: Jan 2009
Reputation: 30
Location: Switzerland
Post: #2906
(2013-07-15 12:16)Tolriq Wrote:  Just noticed a change in last gotham during some tests.

It seems that now neither the title nor the label are filled when playing a random file via JSON.
Before label was filled with the filename (without path) and seems a good thing since the label is a mandatory item.

Edit :

After some debugging I'm lost on what seems multiple strange things, so don't know if they are errors or if normal and so where I should patch.

In CPlayerOperations::GetItem

Code:
else if (player == Video)
      {
        if (!CVideoLibrary::FillFileItem(g_application.CurrentFile(), fileItem, parameterObject))
        {
          const CVideoInfoTag *currentVideoTag = g_infoManager.GetCurrentMovieTag();
          if (currentVideoTag != NULL)
            fileItem = CFileItemPtr(new CFileItem(*currentVideoTag));
          fileItem->SetPath(g_application.CurrentFileItem().GetPath());
        }
      }
      else
      {
        if (!CAudioLibrary::FillFileItem(g_application.CurrentFile(), fileItem, parameterObject))
        {
          const MUSIC_INFO::CMusicInfoTag *currentMusicTag = g_infoManager.GetCurrentSongTag();
          if (currentMusicTag != NULL)
            fileItem = CFileItemPtr(new CFileItem(*currentMusicTag));
          fileItem->SetPath(g_application.CurrentFileItem().GetPath());
        }
      }

When playing a video file the second else block will also be called is this intended ?
Why? It's an else if (player == Video) which should be hit for video files and then it's an else which should only be hit for audio files

(2013-07-15 12:16)Tolriq Wrote:  In CVideoLibrary::FillFileItem
Code:
CVideoDatabase videodatabase;
  if (strFilename.empty() || !videodatabase.Open())
    return false;

  CVideoInfoTag details;
  if (!videodatabase.LoadVideoInfo(strFilename, details))
    return false;

  item->SetFromVideoInfoTag(details);
  if (item->GetLabel().empty())
    item->SetLabel(CUtil::GetTitleFromPath(strFilename, false));
  if (item->GetLabel())
    item->SetLabel(URIUtils::GetFileName(strFilename));
  return true;

Since the file is started from JSON for first time it's not yet in any database so
Code:
if (!videodatabase.LoadVideoInfo(strFilename, details))
    return false;

Will return false and the label is never set.
It should be set/retrieved by CGUIInfoManager which also does this when playing a random file from the GUI.

(2013-07-15 12:16)Tolriq Wrote:  Then on the last part I'm not sure to understand, you test if the label is empty then set it, then you set if the label is present and set it again ?

Not sure what part should be patched and with what Smile So waiting for more details

That second if condition looks wrong and should be the same as the first one. It's possible that CUtil::GetTitleFromPath(strFilename, false) is not able to determine a title from the path and returns an empty string so as a last resort we just use the filename.

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.

[Image: badge.gif]
find quote
Tolriq Offline
Donor
Posts: 2,185
Joined: Jun 2009
Reputation: 67
Location: France
Post: #2907
Quote:Why? It's an else if (player == Video) which should be hit for video files and then it's an else which should only be hit for audio files

Well using debugger it does goes in Smile Perhaps some kind of compiler optimizations of whatever. (On the next part the else does contain player == Audio and does not trigger)

Quote:It should be set/retrieved by CGUIInfoManager which also does this when playing a random file from the GUI.

Well as you know when playing items from JSON we don't go through all the GUI things Smile
And since the Label is a mandatory field as per description and since the beginning it must be also returned in those cases.

Quote:That second if condition looks wrong and should be the same as the first one. It's possible that CUtil::GetTitleFromPath(strFilename, false) is not able to determine a title from the path and returns an empty string so as a last resort we just use the filename.

Thanks for confirming this code is also present in AudioLibrary code.

The possible solutions are to either move the setlabels before the return false.
(Should not be a problem since SetFromVideoInfoTag don't seems to override the label)
Or to fill the label in GetItem code (seems less smart but well Wink )

Yatse 2 : Media Center Remote Control for Touch Screens
Yatse, the Xbmc Remote and Widgets for Android
(This post was last modified: 2013-07-15 13:09 by Tolriq.)
find quote
Montellese Online
Team-XBMC Developer
Posts: 3,477
Joined: Jan 2009
Reputation: 30
Location: Switzerland
Post: #2908
I fixed the bad conditions in 80bb9b93db6a70762b7c05ed6b1e98451c9606bc. I don't have time to look at the rest now but will do later.

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.

[Image: badge.gif]
find quote
Montellese Online
Team-XBMC Developer
Posts: 3,477
Joined: Jan 2009
Reputation: 30
Location: Switzerland
Post: #2909
I can't reproduce the problem you see in the debugger. If I start an MKV that is not in the library through Player.Open and then call Player.GetItem it does NOT go through the audio player specific code.

I have done some refactoring to CFooLibrary::FillFileItem concerning the label (see db911a5f88ef054840b3dc3b98bf342845361506) although it doesn't make any difference when starting playback of an item but it makes a difference when using Player.GetItem.

Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.

[Image: badge.gif]
find quote
Tolriq Offline
Donor
Posts: 2,185
Joined: Jun 2009
Reputation: 67
Location: France
Post: #2910
Does work now Smile

About the debugguer issue after a clean and full rebuild it does not do it again, maybe a bug with incremental build at some time.

Yatse 2 : Media Center Remote Control for Touch Screens
Yatse, the Xbmc Remote and Widgets for Android
find quote
Post Reply