Get currently playing song (Plex Headless)

Hi there,
is there a possibility to get the currently playing song for displaying it on a screen via a local API or linux socket on the same device Plex amp is running? A playback position would also be awesome!

Best,
Paul

Hit curl http://xxx:32500/:/eventsource/notifications with any player, as long as it has remote control enabled.

2 Likes

Awesome thank you!

@Paul-Vincent_Roll How are you planning on using this? I am very interested in a now playing function. Thanks

You can see it here.

A quick query about this; I have Plexamp running under Windows 10 on a NUC that connects to my amp. Everything works fine but I’d like to be able to display the Now Playing information on a Pi that’s also showing other information. Is there any way of accessing the elapsed time from the player? The suggestion above returns artist, track and album information plus total duration but I don’t understand the “time” value - it doesn’t reflect the current position in a track? Is there a way of polling the player to get this information? I’ve spent hours searching for a solution but can’t find a simple way to retrieve the required infomation.

Many thanks.

Time is the position in ms. Starting a timer when the info is received and then counting up works for me to get the current position.

1 Like

Thanks for the reply - I did wonder if I’d have to maintain a timer from the start of the track. I checked a number of tracks and the duration in ms is fine … it’s just the actual "time’ value which didn’t seem to relate to anything.

My main reason for asking is because I’ve been working on a Pi with official 7" display that monitors a Sonos player. This works fine, and along with album art and track info shows elapsed time and a progress bar. The problem is that there are stability issues casting from Plexamp using my iPad. I was hoping to keep all of the Sonos monitoring working and just switch to the Plexamp information when it’s active. I think I have some experimenting to do - I’m new to all of this :wink:

You have to start a timer from when you receive the data as the time stamp is the playback position at the time the data is send (as far as I figured). You also get updates on pause / skip / scrub etc.

Yeah I am doing the same with airplay and plexamp both use the same interface.

The way I do it is:
Store a time stamp when the data is received.
On display update get a new time stamp, calculate the time elapse since the data was received and now and add it to the received time stamp.

1 Like

Thanks again for the help - it’s much appreciated. I’ll try to incorporate the Plexamp method into my current code and see how it goes. This is all a long way from writing assembler in the 80’s!

That now works fine with my code and, as you say, you automatically get notified of change of status - perfect! The only thing I’m missing is the album art of the currently playing track. I realise that you’re using a text display but wondered if there’s a way to get a URL to the artwork from the information returned.I guess the track’s GUID could be used with the server to return a URL to the artwork? Failing that, if there’s a way to find the source directory of the track that’s playing I could pull in the folder.jpg

I see there are Python Plex API’s available that may help but wondered if there’s a simpler solution?

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