Yio Remote Community

Plex Integration

Disclaimer: I’m not a programmer! :slight_smile: My experience is limited to playing around with arduino stuff.

So I spent this weekend installing and getting to grips with Qt Creator. It seems pretty straightforward and I’ve got it compiling on my Ubuntu VM. I had a hell of a job trying to get local cross-compiling working, mainly due to incompatible libraries and no Pi Zero to easily pull from. I have ordered a Pi Zero to assist which should arrive later in the week.

Anyway… I butchered Marton’s Spotify one and got it working.

I had to make some changes to the mediaplayer component too, the most critical was setting up the SPEAKER_CONTROL page. I created a CardSpeakerControl.qml. I just used the AlbumModel to store the data and it seems to work nicely (I would propose creating a SpeakerModel in the future to hold more information including supported features). I changed the title from Speakers to Players as it seems more generic and makes more sense for Plex and any other video based systems?

I added some additional context items as well - SHUFFLE, QUEUE and CONNECT (for the speakers). In the mediaplayer code I added the following complementary commands as well: ADD_TO_QUEUE, SHUFFLE, CHANGE_SPEAKER, GET_SPEAKERS.

I don’t think anything is too controversial there as I just extended what was there previously and it shouldn’t break anything as they are optional controls?

Perhaps more controversially I extended the type definition to include Movies, Shows and Episodes as these are need for Video based media players. I would propose that the search page is refined to only show the types that are returned . This means that audio integrations will never show Movies, etc.

That’s about it for now. I haven’t tested this on my remote as I am waiting on another Zero to turn up. If anyone knows an easy way of cross-compiling by pulling the required ARMv6 libraries without a slave Zero I would love to hear it! I guess it’s a one time thing so maybe someone could host a slimmed down root filesystem??? I think guidance on cross-compiling is worth adding to the Wiki??

On the Plex side of things, I have only done cursory testing with video and movies. The biggest hurdle is that I haven’t got ADD_TO_QUEUE to work with the API at the moment. I’m not sure of what is required. I’m currently trying [server address]/playQueues/[playQueueID]?type=[content type]&uri=[server path or server://machineIdentifier/com.plexapp.plugins.library]/library/metadata/[contentId]&repeat=0&own=1 but while I’m not getting an error nothing is being added to the queue. Worse when I try to refresh the queue via [player address]/player/playback/refreshPlayQueue?playQueueID=[playQueueID] it crashes the player!

Once I’ve got this working on the remote, Marton let me know if you’d like to roll anything up more generally? I have no idea how GitHub works so would appreciate some guidance. I’ll create another thread on this topic…about reporting bugs and feature requests as I’m a complete noob!

1 Like

If anyone cares… the ADD_TO_QUEUE problem was simply solved by changing from GET to PUT (POST returns an error). There appears to be a bug where if you add to a playlist it starts adding at position 2. If you’re building your own playlist it works fine. This issue seems to be widely reported on the Plex forum so I’ll move on for now.

…and updating of refreshPlayQueue is an issue with iOS. I’ll add a platform check to the code… :-/

Wow! That’s really cool you’ve managed to make it work! :slight_smile:

We had plans to extend the media player functions with also speaker control/multiroom support. It’s a bit more complex task I believe, but we would definitely want to make it work as we also use these things :slight_smile:

I see it as two tasks: one is the integration, the backend that communicates with a plex server. The other one is to extend the media player functionalities to support movies/tv shows, etc.

The core principle behind the app so far is that we have a unified UI that looks the same no matter what integration is displaying information. And the UI changes based on the features the integration supports. Easiest example is a light entity. If it can dim, you see a different UI and have different functionality than if you have just an on/off capable light. But it doesn’t matter if it is controlled by Home Assistant or Homey. The same is true for media players.

So I think it’s great that you have this running. It’s a good start and I think it would work also on the remote as well if it works in a VM.

I think the mediaplayer interface needs to be extended to cater for these new things:
https://github.com/YIO-Remote/integrations.library/blob/master/src/yio-interface/entities/mediaplayerinterface.h

And also how it will translate to the config.json file at the end. These two things should be generic, so other integrations can also use them. Nothing plex-specific. The plex integration will take care of translating between the YIO entities and the plex commands.

What you guys have done makes complete sense even to an idiot like myself! I’ve tried to minimise any changes that could be considered Plex specific outside the integration - hence just the adding of (likely) common commands like “shuffle” and “add to queue” so I could test the functionality. It’s omission won’t break anything just reduce functionality. The same with TV and Movies, they just won’t (shouldn’t) show up.

Excited to see what you guys come up with for the Speakers section. I just had to create something to test the integration properly as it was a necessary feature. Should be easy to tie into whatever you see that page developing into. Don’t know if you see a distinction between Speakers and Sources/Players.

It won’t break anything. Just these definitions are in a shared library, so if we change something, then we need to update all the other integrations as well to use the up-to-date library. Better not to do this too often :slight_smile:

It’s actually a tough one. Some speakers can be sources and players as well sometimes.

I finally got time to get cross compiling up and running and it seems to run on the remote as well. I just can’t test it at the moment due to my screen issues.

image

1 Like

Here’s a video of the Plex integration I’m running on my remote. Seems to work pretty well. Sometimes there’s the odd kink that still need working out like the state not updating in the video (although it’s normally okay and becomes more responsive once a direct polling connection to the player is established). It seems different players are more responsive than others and the cheap android tablet sucks!

The bug I mentioned about the playlists before (adding next instead of at the end of a playlist) is actually not a bug. Spotify does the same thing. I guess it stops your requests getting lost at the end of a long playlist.

One issue I have is that artwork does not always load in the main window when songs are skipped, I need to drop out the player and then go back in to see the updated artwork.

As you can see in the video there are no images for the playlists because Plex does not provide this. It would be good to have some default artwork - maybe different coloured squares with a letter in? This could be used as a fallback but as they would be linked to content (first letter) it would look more interesting than just blank tiles? It seems a lot of apps do this - including Plex.

Not shown in the video is also a Now Playing playlist. This appears at the bottom unfortunately as it seems to take the longest to generate. Would make more sense for it to appear at the top - perhaps some kind of sort feature could be added?

I’m looking forward to your hierarchical media browsing update. Currently TV seasons are just listed in a long list under the show.

1 Like

This is super cool @nickprice! :slight_smile:

I also came across the artwork loading issue and I think I know where it’s coming from. I’ll look at it. Should be an easy fix :slight_smile:

Good idea for the “default” album arts. Will have a look at that as well.

Could you link to your github repo, so other people could also try this one out?

I will look at uploading it to GitHub. I’m not totally sure how it all works but can work it out!

One issue is that I had to update the mediaplayer entity to include the ability to choose the player/speaker. Without this you can’t choose what to control. It defaults to the first available player at the moment so as long as you only have one player active it should work. You’ll also lose the ability to queue and shuffle items.

Are there plans to add an expanded command list to the entity? Would also be good to have access to the physical buttons beyond the volume keys.

I see, then we need to extend the media player entities. You are welcome to create a pull request on that as well.

I have plans to integrate proper multiroom handling when I’ll have more time.

I put my crappy code here:


Please don’t judge too harshly! And I also created a version of the remote-software that runs with it here:

Removed
I don’t think my changes should be incorporated into the main thing as it’s really just a hack to get it to work and it would benefit from things like the development of a source/speak model to hold applicable metadata. Also the speaker page is just a hack of your album view! I’m happy to update the integration as you evolve the mediaplayer entity.

FYI the version of remote-software I pulled today crashes on my VM if I don’t comment out the Bluetooth initialisation in main.cpp. Don’t know if a workaround exists for running it on Linux versus the Pi.

I uploaded an update that now has Recently Added playlists for Music, TV Shows and Movies. I also created a repository with pre-compiled binaries if anyone wants to try it. You will need to copy over the remote binary as well for it to work properly (it uses the latest version as of today).

In addition I have temporarily hacked the AlbumView.qml to allow you to click through one level to move from Albums shown in Album view to Tracks shown in Album view. This is a fudge while the hierarchical/browse functionality is being worked out but allows you to select Tracks in recently added Albums.

You can find the binaries here:

For configuration there is a an example config.json or you can use the web configurator.