Editing the API source code for Custom Commands/Development
#1
Where in the source code would I find the code that deals with the API functions?

I want to have the API pause command turn off my monitor when I pause and wake up the monitor when it is unpaused. The goal is to be to turn the TV in my sons play room off and on when I pause/unpause his shows.
I will be more than happy to share my code when I am done and suggest it for a future release. The pause command in the API does not current take any perimeters. I will simple add one that enables my function.

i.e.
http://192.168.1.102:8181/xbmcCmds/xbmcH...orControl)

The problem -
My first solution was to use an IR blaster to turn the TV on and off. However, I can not find a way to detect if the Monitor is powered on or off through Linux. There is a way to put the Montior into a "Sleep" mode which basically turns it off without powering it all the way off and check the status to see if it is in that mode. Xbmc has this feature as well, it can be set in the settings under powersaving, but the HTTP API can not wake up the monitor from sleep mode, you must press a key on the keyboard.

http://stackoverflow.com/questions/34332...mmand-line
Reply
#2
it's cleverly hidden in xbmc/interfaces/http-api/
Reply
#3
isn't the Web Server HTTP API obsolete / deprecated now in favor of the new JSON-RPC API?

http://wiki.xbmc.org/index.php?title=Httpapi
Quote:THIS API IS DEPRECATED As of the Dharma release of XBMC, this API is deprecated. Use the JSON RPC interface instead.
http://wiki.xbmc.org/index.php?title=JSON_RPC

so maybe ask there question here? http://forum.xbmc.org/showthread.php?tid=68263
Reply
#4
Thanks, I was looking all over the place in the lib folder, never occurred to me to look in the most obvious place!

I believe this is what actually pauses it, the if statement before references a slideshow, which I assume is an actual picture slideshow?

Note:The code I am quoting is not PHP it is the C++ in source I dont know how to quote it otherwise..

PHP Code:
else
      
g_application.getApplicationMessenger().MediaPause();
    return 
SetResponse(openTag+"OK"); 

I do realize that this is depreciated however, I use XBMC remote for iPhone to control it and I believe that it uses the HTPP. If I get it working here I will implement it in the RPC. For now Im going to do a quick and dirty hack, I am simple just going to call a php script that will do my code ( since I already know it works ). After I get that working, Ill code it in C++ for HTTP with parameters, then finally Ill convert it over the the new RPC protocol.

PHP Code:
if (showingSlideshow && theAction!=8) {
      
CGUIWindowSlideShow *pSlideShow = (CGUIWindowSlideShow *)g_windowManager.GetWindow(WINDOW_SLIDESHOW);
      if (
pSlideShow)
        
pSlideShow->OnAction(CAction(ACTION_PAUSE));
    }
    else
      
g_application.getApplicationMessenger().MediaPause();
    return 
SetResponse(openTag+"OK");
    break; 
Reply
#5
With JSON-RPC you could have a script running on your machine alongside XBMC and listen to the JSON-RPC notifications and if you get Player.OnPause you could start your script that turns off the tv. That way you wouldn't have to hack around in XBMC's code.

EDIT: Forgot to mention that it doesn't matter how you pause playback i.e. whether you do it in XBMC itself or through JSON-RPC or HTTP-API. The Player.OnPlay, Player.OnPause and Player.OnStop notification will always be sent.
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
#6
It works! I added one line of code, that executes my PHP script and compiled. Now, I dont have to worry about the TV staying on. However ./configure did not detect VDPAU, so I lost out on hardware acceleration.

(2012-06-11, 21:48)Montellese Wrote: With JSON-RPC you could have a script running on your machine alongside XBMC and listen to the JSON-RPC notifications and if you get Player.OnPause you could start your script that turns off the tv. That way you wouldn't have to hack around in XBMC's code.

EDIT: Forgot to mention that it doesn't matter how you pause playback i.e. whether you do it in XBMC itself or through JSON-RPC or HTTP-API. The Player.OnPlay, Player.OnPause and Player.OnStop notification will always be sent.

Montellese, that would be awesome because I want to do the same thing whenever I pause the show with the LIRC remote. Right now the monitor only turns off whenever I execute pause through HTTP API.

Can you point me in the right direction to understand JSON-RPC and listen to XBMC commands? I know little about of JSON-RPC, I would not even know where to begin.
Reply
#7
http://wiki.xbmc.org/index.php?title=JSON-RPC_API describes how you can access XBMC's JSON-RPC API and it has links to the JSON-RPC 2.0 specification etc where you will find more information. For Eden you can then look at http://wiki.xbmc.org/index.php?title=JSON-RPC_API/v4 to see what methods/notifications XBMC exposes. You'll be mostly interested in the Player notifications (see http://wiki.xbmc.org/index.php?title=JSO...4#Player_3).

As you seem to know PHP, IIRC there is a PHP script/framework floating around somewhere which simplifies using XBMC's JSON-RPC API.

As an FYI, as you are interested in notifications you must use TCP (not HTTP) to connect to XBMC because the notifications are not available over HTTP.
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

Logout Mark Read Team Forum Stats Members Help
Editing the API source code for Custom Commands/Development0