HTTP API support for playlists

Is anyone aware if/when/how the HTTP API will allow you to start playing a playlist on a Plex Home Theater client?

 

Currently I get a <Response code="500" status="Could not find that item"/> when I use the playlist key from /playlists however playing a single file works ok.

 

Detailed info:

The HTTP command I am using is:

http://:/player/playback/playMedia?key=&machineIdentifier=&address=&port=

 

The playlist key looks like:

/playlists/14857/items

Having done some digging with Wireshark, I've found that the playlists actually leverage playqueues when playing. The general process looks to be that a playqueue be created with the playlist key via

/playQueues?playlistID=14857&shuffle=0&type=audio&uri=library%3A%2F%2F%2Fitem%2F%252Fplaylists%252F14857%252Fitems&continuous=0

This returns a playqueue ID which is then sent to the client telling it to play.

When I replicate the above command in chrome I only get  (where as the output in Wireshark has much more information)

Does anyone have any documentation on the playQueue API so I can see what I'm missing? 

I'm looking at the same thing right now. Documentation about HTTP API would be very welcome.

I'll let you know when I find something, just wanted to write out there that I am really interested in this.

OK, I figured it out. The problem is that you need X-Plex-Client-Identifier header. See these curl commands:

# get list of clients
curl -i -s -k  -X 'GET' \
    -H 'X-Plex-Client-Identifier: 12345678-abab-4bc3-86a6-809c4901fb87' \
        'http://192.168.1.1:32400/clients'

get list of playlists

curl -i -s -k -X ‘GET’
-H ‘X-Plex-Client-Identifier: 12345678-abab-4bc3-86a6-809c4901fb87’
http://192.168.1.1:32400/playlists/all?type=15&X-Plex-Container-Start=0&X-Plex-Container-Size=50

create playqueue playlist

curl -i -s -k -X ‘POST’
-H ‘X-Plex-Client-Identifier: 12345678-abab-4bc3-86a6-809c4901fb87’
http://192.168.1.1:32400/playQueues?playlistID=181334&shuffle=0&type=audio&uri=library%3A%2F%2F%2Fitem%2F%2Fplaylists%2F181334%2Fitems&continuous=0

curl -i -s -k -X ‘GET’
-H ‘X-Plex-Client-Identifier: 12345678-abab-4bc3-86a6-809c4901fb87’ -H ‘X-Plex-Target-Client-Identifier: 99999993-ba46-40ff-80ff-999999999999’
http://192.168.1.1:3005/player/playback/playMedia?protocol=http&address=192.168.1.109&key=%2Flibrary%2Fmetadata%2F170872&offset=0&commandID=1&port=32400&containerKey=%2FplayQueues%2F2045%3Fown%3D1%26window%3D200&type=music&machineIdentifier=1231231231231231231231231231231231231232

Actually the funny thing is to get things like machineIdentifier and things like double-url-encoded parameters. I made a simple Ruby code to play a playlist by name.

@jooray, thanks very much for researching this. Your Ruby script works for me up until the last step: actually starting playback on the client (a Roku device). It finds the correct host and the playlist fine. What client are you using with your script?

I’m guessing that casting to Roku works differently. When casting to Roku from the Plex app, the PMS log file shows some sort of “delegation” request that transfers control to the Roku client, which then issues its own playQueues request. Any further insight would be very welcome.

…and I confirmed that your script does work with the Plex Home Theater application. Thanks again for that.

@jooray

thanks for the examples above however im having some trouble getting these to work
can you confirm where / how you are adding an item to the play queue that you created?

i was able to create the play queue using your curl command above but everytime i do get /playQueue? it lists my newly created play queue but it has an item count of -1

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