Kindly request for some simple additional commands for HTTP API/Control

Hello,

 

I'm trying to build a minimalistic way to control my home cinema.

Using the Apple Remote for it, but not only for Plex. (I have a contol application, which can switch between different things to remote-control (light, AVR, Projector, etc.)

I'm quite happy there is the HTTP API/Control for Plex Client, but I miss just a few things there:

The Remote control's Menu-Button function (that switches automatically between the current API functions "back" and "toggleOSD" depending on the current situation)

The Remote control's Play/Pause-Button function (that switches automatically between the API functions "select", "play" & "pause" depending on the current situation)

The cursor buttons can only have one function, either menu control (up/down etc) or volume/forward/backward within a movie.

 

So basically what I'd love to have, would be a simple copy of the general/Apple Remote Control functionality as a new set of API commands.

The behavior of these functions should be the same as if I used the infra-red remote buttons, just fed into Plex by API commands.

 

Currently I use the workaround to constantly poll the Plex client in which state it is, so that I open the OSD when playing, etc. Very complicated and not comfortable.

(Other forum posts already have that problem covered, which I copy here:

it would be great to have a way the Plex Client shouts its current state instead of constantly being polled by an external app)

 

Thanks a lot & keep up the great work!

 

Ardego

I am trying to do the same. When controlling my Mac i simulate keystrokes instead (i.e., using AppleScript with keystroke) which works pretty much as you want it to work. For example, sending ENTER will trigger a select when in menus, but a play/pause toggle that brings up or hides the OSD. Similarly for other keys (e.g., UP/DOWN etc.).

However, while current HTTP API although appears to support sendKey (see http://wiki.plexapp.com/index.php/HTTP_API/Control#Application_Controller), it does not appear to work in practice (neither e.g., the Screenshot functionality). I'm not a Python developer, but row 15 in playerkit.py that holds some of the functionality for the HTTP API reads

#TODO: Screenshots, key chars

So, potentially some of this functionality might not currently be working. When this is fixed (if it indeed is not implemented yet), maybe you can use this? Another solution might be to manually emulate keystrokes as I outlined above. Happy to help you get started if helpful.

Thanks a lot, mkirsten!

That was a great idea! Didn't think of trying the keyboard for similar behavior & missed the sendkey command altogether, too bad it is not fully completed yet.

So my Problem is *almost* completely solved, but I couldn't yet copy the Menu button function.

In the menus it needs to go "back", and in the OSD it needs to hide it,

so I'm still using the workaround alternating the "back" and "toggleOSD" commands when playing or paused (polling the client for the state every second),

as the submenus for video & audio will not be closed using "toggleOSD". Only disadvantage is that every other click simply does nothing after playing around in the menus while playing/paused.

For the rest I actually used both your suggestions:

The Select/Play/Pause function seems to be exactly the "Return" key, which actually works by the sendkey HTTP command   :)

http://MacPro.local:32400/system/players/mac-mini.local/application/sendKey?code=13

The keyboard cursor keys are also exactly the left/right/up/down buttons from the remote, but I found no way to sendkey them, guess its only ASCII characters that can be submitted.

so I used a simple Apple script for each of the cursor keys (remove the "--" from the command you need):

on run

    tell application "Plex"

    activate

      tell application "System Events"

     --key code 123 --left

      --key code 124 --right

      --key code 125 --down

     --key code 126 --up

 

 

     -- these below worked too, but I used sendkey & navigation HTTP-API commands instead:

       --keystroke return  -->select/Play/Pause

       --keystroke "m"     --> toggles the OSD

       --key code 53         --> ESCAPE key, going back

      end tell

   end tell

end run

 

The script is pretty quick from within my Realbasic app, so I even can quickly press the buttons if I need to.

 

So the sum up of my kindly request for the Plex developers:

1. Including a copy of the remote controls "Menu/back" button, the "Enter" key and the cursor functions into the HTTP API would be much appreciated

2. The polling for the current client state using "http://MacPro.local:32400/xbmcCmds/xbmcHttp?command=GetCurrentlyPlaying"

     seems to be a bit limited for several users who want to integrate the Plex client into their home cinema environment,

     so it would be great to have a event callback function in the plex client that one could either hook into via some .dylib/.dll

     or some IP-socket events that could be send to a pre-defined listener destination.

     (easier to access, but this would need a settings field where the user can enter a network-address where these events are sent to)

     This could easily provide much more events than just playing/paused/stopped etc.

     For example to get information when Volume up/down is pressed while using digital output, to remote control an Audio-Video-Receiver instead of the internal volume

     (I'm using my Apple remote for changing the volume of my AVR while Plex is playing, otherwise I control Plex with it; But doing this I cannot give Plex.app itself the full control over the remote)

3. For others who can't or don't want to code their own application for this, it might even be useful to include a simple serial command option, at least for volume up/down of an external AVR instead of changing the volume of the computer.

     Settings for the user to select would be just a few: COM-Port, Baudrate, Bits, Parity, Stop-bits, XON, CTS and DTR. Plus the two individual commands to enter for master volume up & down of the AVR.

     For example, for my Denon this is simply "MVUP"+chr(13) and "MVDOWN"+chr(13)

     Hook up a serial cable, finished.  B)

 

Thanks again!

Glad that you a little bit further. I'm using a Bang & Olufsen Beo4 remote and have different keys for the OSD and BACK in menus so hence have no need to determine state to get the behavior right, but I see what you mean for an Apple remote.

My 5c is that while (3) seems a bit over the top (as there are workarounds for this outside Plex), (2) is a nice addition and (1) I would really hope to see soon. Plex is a great puzzle piece of a great home media setup and I think more and more users are looking for a neat integration with other systems to control.

Best of luck with your setup!

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.