PlexDevices - Custom Media Player Component

Well this was certainly a weird bit of testing.

Here’s me casting to the Shield; shows in normal plex client all controls work. Plexclient on the bottom shows my previous session with Plex media server on the Shield BTW. :

Now here’s me playing an episode of the greatest TV show in this timeline, from the Shield’s Plex Server. Shows in Plexclient client, full info and screen but no operational controls. They show, but do nothing. Standard Plex client is dead - nada - nothing. It’s the media player equivalent of Birdperson.

Client in the middle? I have no clue. It doesn’t seem to respond to anything nor does it show any media. Not even for any of the other media like YouTube. It has a cast icon in the upper left hand corner but I have no idea where it’s coming from…

Non Plex media content doesn’t seem to show in any media player; I’m guessing to support the Shield, some kind of Android Media Player client would have to be developed.

Hope this helps, let me know if I can give you any more info.

2 Likes

I can reproduce the same issues. I’m going to setup a new environment and test using the plexapi vs plex web api (I imagine the former works as I’m using the later). If so, I’ll copy the ha plex component, add my enhancements, and test. If all good, I’ll publish to GitHub so you all can test.

2 Likes

So I think I see whats going on which will take me many days to get right. I may go radio silent in the meantime. See below if you care about the details. Bottom line - I have to use the existing ha plex client and merge some of my changes carefully.

problems:

  • ha plex only polls plex clients, not plex players. For example, playing a music track through the plex web player will not display in ha plex (but will display in the plexclients version I am testing). Another example, plexconnect apple tv’s won’t display in ha plex but do display in my plexclients because I trigger off of players instead of clients. So devices are missing from ha plex but all display on my plexclients. However the missing devices do not seem to be controllable (probably because they are not clients). So I’d have to use the existing ha plex code, determine the missing devices, and blend them in (with controls disabled).
  • ha plex uses the plexapi which doesn’t seem to easily expose an offset (i.e. how many seconds a media has played vs the entire duration). Without that, I can’t display a progress bar - so back to problem above where I’ll have to get that from plexclients and merge into ha plex
  • There is no way to retrieve volume or mute state remotely. So I’ll have to fake it so ha will be in sync with plex whenever you use ha to control plex volume/mute but it will become out of sync if someone controls the volume/mute on plex directly
  • Other minor stuff - make the visual changes I made (display season/episode numbers and names, display episode thumbnail, etc)
2 Likes

Yes, I do care and thanks for all your hard work! Let me know if I can be of any help in testing or anything.

1 Like

The core enhancements on the existing media_player.plex are done (see below). Now for the hard part (adding the missing plex players).

Enhancements so far:
- Controls:
- On/Off: On does nothing but Off stops playing media (good to kick of unwanted users / kids past their bedtime)
- Volume/Mute: Can set and mute (Plex client syncs with what HA tells it, not the other way around)
- Progress: Display a media progress bar
- Movies:
- Display name as “Name (Year)”, ex. Blair Witch (2016)
- Display library name below movie title (ex. “Adult Movies”)
- TV:
- Display episode and season numbers with leading 0’s, ex 02, 05
- Display “Show S##E##”, ex. Rick and Morty S02E05
- Display episode thumbnail instead of show thumbnail
- Music:
- Display Artist (track artist, if not use album artist)
- Set albumn name property



3 Likes

First thought when seeing the thumbnail:

“Where is my metadata, Summer?”

You got this worked out pretty quickly - was not expecting to hear from you this fast! Keep up the great work!

Heads up Plex/Home Automation fans! :smiley:

1 Like

Sounds interesting but why use this when the existing Plex component already report the same stuff. What am I missing here?

It doesn’t - please review the earlier comments and images.

Sorry. I am referring to @GraysonPeddie message about webhooks on Plex.

Web hooks are good for simply action / reaction (media plays, turn on lights). I use something similar for my Blue Iris setup. If that’s all you need, then use the web hooks.

This not only allows you to do the same but it also:

  1. Provides you with a visual map of what’s occurring on your plex server (looks cool too)
  2. Allows you to manually respond to events
  3. Allows you to manually control players (i.e. a single page to remote control every client connected to your plex server)
  4. Easier setup and maintenance (nothing to configure on your plex server, nothing new to learn/manage)
  5. Doesn’t require a plex pass subscription
  6. Extensible - Ex. In this component, you can expose any plex property (ex. maybe you want an alert when your kid starts playing a rated R movie)

OK, so I got all the code woking but need until the weekend to test and optimize. Maybe I can get all this working with the plex API (where right now a small piece is still REST).

2 Likes

Great to hear that. I am actually using a custom component for Plex from Workout Script w/ Plex Video Control . From there, I modified it so that I can create a script or an automation to play a playlist from my Plex account.

Is your version able to support playing a playlist or any media type as well?

Problem - it works but my original code (which doesn’t reliably control playback) is much faster. I mean almost instantaneous vs 5-10 second lag using media_player.plex’s method of using the python apir. Might be because the API is communicating through Plex.tv? Don’t know. I’m going to experiment with a version that uses my original code for everything except for media control (I’ll use the python API).

First time I ever saw a dev say that ‘much faster’ is a problem. LOL

2 Likes

Send me all your code and I’ll incorporate the feature

NO WAY - Got it working off your linked post (with a movie anyway - going to test the other types)

It all works (remote play of movies, tv shows, and music play lists). I’m going to try and add playing individual tracks/artists/albums in addition to playlists). Pretty cool. Will update shortly.

5 Likes

PLEXDEVICES 0.1 - Renamed and ready for testing

Scroll up to the first post for links to the latest Code and Documentation

5 Likes

OK - that is cool. I will try it out this weekend.

1 Like