Kodi Community Forum
WebServer HTTP API (HttpApi): for PocketPC and Web-client Remote Control Apps - 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)
+--- Thread: WebServer HTTP API (HttpApi): for PocketPC and Web-client Remote Control Apps (/showthread.php?tid=8760)

Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38


- nad - 2007-02-23

Hi Drongo,

That httpapi call just returns whatever the core system returns to it - it doesn't change anything apart from changing a returned empty string to the error message you reported.

Looking into the code which returns PlaylistLength there is a check to make sure that audo is being played and if not an empty string is returned. I presume the logic is if there is nothing playing then there is no active playlist length.

You could use GetPlaylistContents and count the number of entries. If you are not able to do that in your code then I could add an hhtpapi GetPlaylistLength.


- nad - 2007-02-23

startup and shutdown broadcast events added.


- Drongo - 2007-02-24

Nad, yes please, can you add a Getplaylistlength

Cheers


- nad - 2007-02-27

Just added GetPlaylistLength. It takes the same form as GetPlaylistContents.


- znelbok - 2007-03-09

Obviously no one uses the httpapi. Looks like I will struggle on without out help

Mick


- LiquidIce629 - 2007-03-10

znelbok,

Are you accessing the two servers by their hostnames? Try using the IP address instead, maybe xbmc is having a problem resolving the server2 hostname?

Also, do you have bookmarks created to both servers? Make sure shares on both servers are boookmarked, and try the httpapi call again.

I use the httpapi, and while it has it's quirks, it is still extremely useful. Recently, I've found that using SPYCE (.spy Python Web Pages), the web server can be even more robust, because not only can you call HTTPapi commands, but you can use any python scripting as well.
Since there is loads of examples of python scripts written for xbmc it's pretty easy to learn spyce. Basically spyce is an xbmc script, except it outputs as html to a web browser instead of to the tv screen.

Quick example of spyce in action:
addtoplaylist.spy (called like this: http://xbox/addtoplaylist.spy?file=smb://server1/file.mpg )
Code:
[[
import xbmc
print xbmc.executehttpapi("AddToPlaylist("+request.get("file")+");0")
]]

--

A few months ago on another forum post, I brought up the possibility of using JSON with XBMC. Now that I've gotten the hang of SPYCE, I think it would be very possible to build a JSON implementation into XBMC using SPYCE to generate the data and pass commands to xbmc.
The usefulness of generating JSON is that the data coming back does not need to be parsed with messy <li> strings. It comes in as a string that automatically gets converted into an object in whichever programming language you happen to be using (JSON works with quite a few). Would something like this be useful for anyone else?


- nad - 2007-03-12

LiquidIce: don't forget you can use SetResponseFormat to get rid of the "messy <li> strings".


- Nuka1195 - 2007-04-21

nad,

deleted old post as I now know it is correct Smile

but,

can

xbmc.executehttpapi( "getguisetting(0,videoplayer.displayresolution)" )
and
xbmc.executehttpapi( "SetGUISetting(0,videoplayer.displayresolution,1)" )

be used without the webserver running?


- Nuka1195 - 2007-04-22

bump for nad


- nad - 2007-04-24

I would expect so. Since you are asking the question should I assume it doesn't?


- Nuka1195 - 2007-04-26

Yes, the webserver needs to be running for those commands to work.

Someone else posted about scripts now needing the webserver running to use httpapi, when in the past it didn't.

http://forum.xbmc.org/showthread.php?tid=25915&highlight=webserver

thanks


- pulp_136 - 2007-05-11

Nad, I would also like to thank you for the API. I had tried some years back but gave up on it since it wasn't very stable. It seems very stable now.

I went through the docs many times, but I can't find any commands to change (or cycle through) the subtitles and the audio stream. Did I overlook it?

I'm not talking about the settings for the font, colour etc. but the subtitles themselves. I hope it's clear.

cheers
pulp


- pulp_136 - 2007-05-24

bump

anyone on how to change subtitles and audio stream?

pulp


- nad - 2007-05-24

Hi Pulp: I am in the middle of a house move and have lost my Internet connection. I hope to be back on line in a week or so.

There aren't any specific httpapi commands for the settings you are after though you might be able to get to something via the Config or ExecBuiltin httpapi commands.


- pulp_136 - 2007-05-29

thanks Nad, I 'll try that.

I can also make this through the keymap.xml and PC IR control that I have anyway in order to switch on the xbox. What concerns me in such a solution would be the missing feedback through the API or at least through the TV. You understand that the ability to cycle through the subtitles would be of no use without some visual feedback to give you the name of the selected subtitle.

I'll let you know how it goes.
pulp