Control XBMC via HTML

  Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
hernandito Offline
Fan
Posts: 456
Joined: Feb 2011
Reputation: 5
Post: #1
Hi Guys,

I have what I hope is a basic request. I am trying to create a "home" web page for my home system. I have remote XBMC machine that I would like to control remotely via this page.

I want to issue some basic commands to the XBMC machine like Update Library, Reboot, etc. What would the html code look like to do this? In my unRAID NAS I have PHP and Curl installed. My web page is hosted on the NAS. Puttying to my NAS I can type the following command pointing to the XBMC machine:

Code:
curl "http://192.168.0.102:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn&parameter=XBMC.UpdateLibrary(video)"

How do I execute the same thing from within a web page?

Many thanks,

H.

p.s. I know I can use the stock XBMC web interface. I am trying to do something a little more custom.
(This post was last modified: 2012-05-08 17:03 by hernandito.)
find quote
whitebelly Offline
Fan
Posts: 385
Joined: Jun 2011
Reputation: 4
Post: #2
Interesting. I can see how this might be useful.

Does the command execute if you request that URL from a browser? If so, a simple hyperlink on a webpage might work.
find quote
hernandito Offline
Fan
Posts: 456
Joined: Feb 2011
Reputation: 5
Post: #3
I believe it does... I tried typing this and it returned to a web page that said OK. I am doing this remotely from work, and I could not see the TV if it initiated the update.

Code:
http://192.168.0.102:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn&parameter=XBMC.UpdateLibrary(video)

The only issue is that I do not want it to go to another page... I want it to stay where it is... My goal is a Maraschino portal page as described on this post:

http://forum.xbmc.org/showthread.php?tid...pid1096923

I am happy to share anything I create with the community.

Thanks,

H.
find quote
jhsrennie Offline
Team-XBMC Developer
Posts: 7,236
Joined: Nov 2008
Reputation: 119
Location: Chester, UK
Post: #4
see http://stackoverflow.com/questions/24748...javascript

You can write a little javascript function that GETs http://192.168.0.102:8080/xbmcCmds/xbmcH...ary(video) and make your link run the Javascript.
find quote
hernandito Offline
Fan
Posts: 456
Joined: Feb 2011
Reputation: 5
Post: #5
Basic HTML is as good as I get... I will give this a try... thank you!!

edit:

I am struggling with this... anyone know of a more clear-cut example?
(This post was last modified: 2012-05-08 21:19 by hernandito.)
find quote
whitebelly Offline
Fan
Posts: 385
Joined: Jun 2011
Reputation: 4
Post: #6
I am very rusty on html, seems like a multipart form using a get method and submit buttons might get you there. Or you could make a 2 frame page and do the hyperlinks in one frame each targeting the blank frame, that would give you the feedback.
find quote
hernandito Offline
Fan
Posts: 456
Joined: Feb 2011
Reputation: 5
Post: #7
Whitebelly I do have a 3 frame page, but the trick is that I do not want to load a whole web page on a frame that simply says "ok".

I think this is close to getting what I need to work... I just need help to change the function to be the part that fires up the command above.

http://www.w3schools.com/jsref/tryit.asp...ef_onclick

I am sure this is javascript for for dummies ....

Thanks,

H.
find quote
whitebelly Offline
Fan
Posts: 385
Joined: Jun 2011
Reputation: 4
Post: #8
Let me know if you achieve success, I might want to something similar.
find quote
Riball Offline
Junior Member
Posts: 3
Joined: May 2012
Reputation: 0
Location: Netherlands
Post: #9
Here is a quick example of what I guess you are trying to achieve.
This depends on jQuery 1.7 tho.

http://jsfiddle.net/sXk6h/2/

Note: This only works when you are already logged in and have an active security session.
(This post was last modified: 2012-05-09 00:01 by Riball.)
find quote
robweber Offline
Posting Freak
Posts: 889
Joined: Sep 2009
Reputation: 27
Post: #10
Seems like you are reinventing the wheel here. Projects like maraschino already have great web interfaces and can control xbmc remotely (shutdown, startup, everything you wanted). it will also run on an unraid server. Worth checking out before you spend too much time on your own implementation.

http://www.maraschinoproject.com/
find quote
whitebelly Offline
Fan
Posts: 385
Joined: Jun 2011
Reputation: 4
Post: #11
maraschino looks really awesome, but is more than what I need for my music only box.

The simple approach of being able to do a small number of discrete commands still interests me. For example, the existing web interfaces that are available for EDEN meet my needs, but depending on which computer or tablet I'm on or what I am doing, I may want to change the interface.... so I'd like to be able to simply send a command that changes the web interface with a simple click on a discrete link/button/cmd from the device I on at the time, then be on my merry way. This thread looked promising to me in that regard.
find quote
hernandito Offline
Fan
Posts: 456
Joined: Feb 2011
Reputation: 5
Post: #12
(2012-05-09 00:00)Riball Wrote:  Here is a quick example of what I guess you are trying to achieve.
This depends on jQuery 1.7 tho.

http://jsfiddle.net/sXk6h/2/

Note: This only works when you are already logged in and have an active security session.

Riball, thank you for this! It is exactly what I needed. I really appreciate your help. There is no way I would have figured this out on my own. NodNod

Robweber, I am very familiar with Maraschino. In fact, what I am trying to achieve is to add some additional functionality to a wrapper web site I created around Maraschino. You can see on my post above what I did. I want to add some additional functionality that is front and center to managing certain things with XBMC. I will post back here my results.

Thank you all.

H.
find quote
robweber Offline
Posting Freak
Posts: 889
Joined: Sep 2009
Reputation: 27
Post: #13
Glad you got it working, although I'm still a little confused on how this is any different than the functionality (and purpose) behind what maraschino already does. Everyone has there own way of doing things I guess.

One piece of advice though, I wouldn't use this command:

Code:
http://192.168.0.102:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn&parameter=XBMC.UpdateLibrary(video)

the XBMC HTTP API has been deprecated since Dharma and will probably be removed by Frodo. The only reason its around right now is so developers have time to transition to the JSON API instead. You can do the same command with JSON, only it would look like this:

Code:
http://192.168.0.102:8080/jsonrpc

//in the data section of the http post request (using jquery this would be simple)

{ "jsonrpc" : "2.0", "method" : "VideoLibrary.Scan", "params":{}, "id": 1}

Your URL will work for the near future but is slated to be removed at some point.
find quote
hernandito Offline
Fan
Posts: 456
Joined: Feb 2011
Reputation: 5
Post: #14
(2012-05-09 19:21)robweber Wrote:  Glad you got it working, although I'm still a little confused on how this is any different than the functionality (and purpose) behind what maraschino already does. Everyone has there own way of doing things I guess.

One piece of advice though, I wouldn't use this command:

Code:
http://192.168.0.102:8080/xbmcCmds/xbmcHttp?command=ExecBuiltIn&parameter=XBMC.UpdateLibrary(video)

the XBMC HTTP API has been deprecated since Dharma and will probably be removed by Frodo. The only reason its around right now is so developers have time to transition to the JSON API instead. You can do the same command with JSON, only it would look like this:

Code:
http://192.168.0.102:8080/jsonrpc

//in the data section of the http post request (using jquery this would be simple)

{ "jsonrpc" : "2.0", "method" : "VideoLibrary.Scan", "params":{}, "id": 1}

Your URL will work for the near future but is slated to be removed at some point.

Thank you Rob,

Sorry I missed your post earlier... I would like to take your advice but could I impose on you to clarify how I would call this within my html? I am not very familiar with scripting or any of the more advanced stuff...Blush

I was hoping I could implement certain things like changing the Skin (looks like it's not doable), and a super quick way of sending update video library and update music library commands. They are there in Maraschino, but I need to pick a few things in the library to get to them. I wanted them front and center as part of my work flow.

Thanks again,

Hernando
find quote
robweber Offline
Posting Freak
Posts: 889
Joined: Sep 2009
Reputation: 27
Post: #15
You'll probably want to look over the JSON API and see what you can get accomplished from there (if you haven't already):

http://wiki.xbmc.org/index.php?title=JSON-RPC_API

As far as doing the calls you'll most likely need to implement some Javascript (JQuery or whatever your preference is) An ajax call putting the json information into the POST Data is what you'll have to look into. I don't have any specific examples but someone else may be able to toss them out - I usually code stuff in python and don't have the html experience either.
find quote