songchenwen / plexdlnaplayer

There is no built in way to cast Plex music to DLNA speakers. This project will be the bridge.
https://hub.docker.com/r/songchenwen/plexdlnaplayer
GNU General Public License v3.0
34 stars 11 forks source link

Really promising - some suggestions #5

Open kevinmarchant opened 2 years ago

kevinmarchant commented 2 years ago

I've been looking for something like this for years (ability to stream direct from Plex to DLNA (specifically my Heos Denon amp). The mods that Garbled1 suggests make it work really well. So thanks !!

Some suggestions if you were thinking of investing any more effort:

  1. could the track metadata (artist / album / coverart) somehow be preserved through the bridge as it's currently not showing. I'm by no means an expert but is this something to do with DiDL if the stream is converted by the bridge?
  2. the docs don't explicitly say this is Linux only - but as uvloop isn't available on Windows and it appears to be a prereq I assume this is the case. Would it work on Windows if asyncio was quick enough ?
  3. I had hoped to run this in a VM (not docker) which has two network adapters. I tried experimenting with HOST_IP in settings but this doesn't appear to restrict the discovery to the correct adapter, it always seems to be performed on the primary adapter and fails to discover devices connected to the secondary adapter.
  4. The additional DLNA endpoints created don't appear to be available for selection in the Plex Alexa skill (at least not within a short time window) - this is probably well beyond our control but my goal was to be able to ask Alexa "Ask Plex to play 'Deacon Blue' on Denon". So close to being able to achieve this!!

Thanks for all your effects, This kind of feature should have been included in Plex directly, but their support for DLNA is lack-lustre at best - and this is really useful.

garbled1 commented 2 years ago

I have no idea how to do 1, 2, 4. :) However, 3, at least as a hack, you can change in plex/plexserver.py and plex/gdm.py where it binds to 0.0.0.0 to the IP of the interface you wish to bind to.

I'm still having heaps of problems with making it work how I want, because I have a 3 speaker setup, and it's not playing nice with the various apps yet. However, I think I have some ideas on that. Do you have more than 1 speaker? Is it functional in all the apps as-is for you?

kevinmarchant commented 2 years ago

Thanks - will give that a try. Will probably convert over to using Docker / Portainer rather than a VM.

I've only got a single "speaker" in terms of the Denon amp, though could use my jRiver nodes as DLNA players to try a pseudo-multispeaker setup at some point.

I wonder if @songchenwen will commit your changes so we call be looking at a single codebase?

garbled1 commented 2 years ago

I'm currently working on a more complex fix, that involves firing up a webserver for each device. So far i have it working so the android client sees all 3 of my speakers all the time, which was my goal. Still fiddling with cleanup of the code tho..

garbled1 commented 2 years ago

Try my res_fixes branch. I think it works. This allows you to host multiple DLNA devices on one instance of the server. I'm still doing some cleanup, but overall, I think it's correct. Need more testing when everyone in the house is awake and I can throw music around. :)

kevinmarchant commented 2 years ago

Sorry for the delay. I set up two additional DLNA endpoints in addition to my Denon server. I can see all three endpoints in the iOS client but only the most recently added endpoint appears in the web client. The media transport controls (play pause etc) don't seem to be working with res_fixes either but to work with Heos_fiddle.

garbled1 commented 2 years ago

OK, hopefully tomorrow I can get some time on the house when people are awake, and fix up res_fixes to the point where audio works.. In theory, the res_fixes branch will fix your 3 endpoint problem.

Curious, what endpoints are you using there? One reason I'm doing this is I want to also setup a small device to throw to some speakers in the back yard, which are not HEOS, so I'd like to know what you used that works.

kevinmarchant commented 2 years ago

I'm using PC software - jRiver Media Center (not free) though I see some projects on GitHub offering free stuff - just for testing purposes as a DLNA endpoint. If I needed back garden coverage I'd use bluetooth from that PC (on which I could must use the Plex client of course or a DLNA rendered) to one of my Bluetooth enabled speakers rather than trying to track down a portable speaker with a DLNA renderer built in (though I guess such things might exist - a quick Google suggest Sonos speakers might appear as DLNA endpoints.)

garbled1 commented 2 years ago

Can you try my res_fixes branch one more time please? I ran it for a few days, found a few glitches, and fixed all those.. and I think it's pretty stable now.

kevinmarchant commented 2 years ago

Looking good. I set up the same three DLNA endpoints as before, and play/pause and volume controls now work (volume a bit slow to react). Same restrictions as before - only the most recent DLNA endpoint appears in web interface; none within the Alexa skill )-:; all three appear in iOS client.

Interestingly, metadata is appearing on my jRiver endpoints (album art, title, song title) but not on Denon )-:

garbled1 commented 2 years ago

Odd, for me the web client is working perfectly... I wonder why yours is different... I'm able to see all my devices in web, android app, and plexamp if I do the registration dance.

kevinmarchant commented 2 years ago

Oh well, I just had another go and it's consistent i.e. I just

Same result. All three available in iOS Plex and Plexamp (latter needed "refresh" button pressing). Only the last one registered available in Web.

If I close down the endpoint that does appear in the Web client, I can see the PlexDLNAPlayer close down the server instance but interestingly the Web list doesn't update, it still shows the unavailable endpoint though you can't select it. The iOS Plex client and Plexamp behave correctly (though again I have to manually refresh the list in Plexamp).

I guess variations might be due to what DLNA endpoints we're using.

garbled1 commented 2 years ago

it might, it might also be that I'm using firefox on linux, and my plex runs on linux. I think the web side is through the GDM broadcasts, which, for me, use a separate port for each device, and work ok.

Maybe you can grab a tcpdump of the GDM traffic sent from the dlnaplayer to plex, and I can compare to mine?