HTTP API/Control

HTTP API/Control

From Plex

Jump to: navigation, search

Contents

Basics

Plex allows for the control of some clients (notably, the Mac and Windows desktop "Plex Media Center" clients) via an HTTP Control API. Basically, by using properly-formatted HTTP requests, you can send commands to that client. This could let you do simple things like pause a currently-playing item or more advanced things like arbitrarily playing a particular item.

Commands take the following form:

http://{server}:32400/system/players/{player}/{controller}/{command}
  • server - The IP address or local host name (e.g. "mac-mini.local") of the media server
  • player - The computer running a Plex client to which you want to issue the remote command. You can get a list of computers running Plex on the network by hitting http://{server}:32400/clients on the current server. This can be the IP address or local host name (e.g. "mac-mini.local") of the computer.
  • controller - The command controller you wish to use
  • command - The command to issue

Available Controllers and Commands

The following controllers and commands are available:

Navigation

Navigation Controller

This controller is accessed via the controller keyword "navigation" when sending commands.

http://MacPro.local:32400/system/players/mac-mini.local/navigation/moveDown

Navigation Commands

The following commands are available for the navigation controller:

  • moveUp
  • moveDown
  • moveLeft
  • moveRight
  • pageUp
  • pageDown
  • nextLetter
  • previousLetter
  • select
  • back
  • contextMenu
  • toggleOSD

Playback

Playback Controller

This controller is accessed via the controller keyword "playback" when sending commands.

http://MacPro.local:32400/system/players/mac-mini.local/playback/pause

Playback Commands

The following commands are available for the playback controller:

  • play
  • pause
  • stop
  • rewind
  • fastForward
  • stepForward
  • bigStepForward
  • stepBack
  • bigStepBack
  • skipNext
  • skipPrevious

Application

Application Controller

This controller is accessed via the controller keyword "application" when sending commands.

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

Application Commands

The following commands are available for the application controller:

  • playFile (accepts the following argument)
    • path
  • playMedia (accepts the following arguments)
    • path
    • key
    • userAgent (optional)
    • httpCookies (optional)
    • viewOffset (optional)
  • screenshot (accepts the following arguments) (does not appear to be working currently)
    • width (default 480)
    • height (default 270)
    • quality (default 75)
  • sendString (accepts the following argument)
    • text=xyz
  • sendKey (accepts the following argument) (does not appear to be working currently)
    • code=01
  • sendVirtualKey (accepts the following argument) (does not appear to be working currently)
    • code=01
  • setVolume (accepts the following argument)
    • level=100

Notes: The playMedia command needs a bit more explanation. This command requires two arguments - the path and the key - and has additional optional arguments. The path should be a PMS URL that returns a MediaContainer describing a directory, for example "http://localhost:32400/library/sections/2/". The key should be the ratingKey attribute of the item within that container that you wish to play. This method has the added benefit of giving Plex enough information to access the metadata of the item rather than just the media (posters and plots show up in the on-screen-display, relationships between tracks within albums are maintained, etc.).

See the examples below to see how some of them work in action.

Examples

A simple navigation command to move down in a list of item:

http://MacPro.local:32400/system/players/mac-mini.local/navigation/moveDown


Toggle the on-screen-display menu while watching some media:

http://192.168.1.4:32400/system/players/mac-mini.local/navigation/toggleOSD


Pause an actively-playing item:

http://MacPro.local:32400/system/players/192.168.1.6/playback/pause


Take a small jump back in time for an actively-playing item:

http://MacPro.local:32400/system/players/mac-mini.local/playback/stepBack

Set the volume to 100%:

http://MacPro.local:32400/system/players/mac-mini.local/application/setVolume?level=100


You can get a JPG image of the current client screen:

http://192.168.1.4:32400/system/players/mac-mini.local/application/screenshot?width=720&height=480&quality=75


This is a "dumb" command to simply play a particular library file. Note that it will have no metadata or other information associated with it.

http://MacPro.local:32400/system/players/192.168.1.6/application/playFile?path=http://mac-mini.local:32400/library/parts/438/file.m4v


Here's a more complicated example that will start playing a particular media item. It includes an offset (in milliseconds), which means that playback starts in the middle - in this case, around 36:33 into the movie.

http://MacPro.local:32400/system/players/mac-mini.local/application/playMedia?key=/library/metadata/147&path=http://mac-mini.local:32400/library/metadata/147&viewOffset=2193449