philippe44 / SpotConnect

Turn any UPnP or AirPlay player into a Spotify Connect device
MIT License
77 stars 3 forks source link

SpotUPnP on Synology DS220j #43

Open spotuser opened 6 months ago

spotuser commented 6 months ago

First of all, thank you so much for this brilliant piece of software! It is exactly what I was looking for since a while, because I have a bunch of DLNA-capable devices (Sony CMT-G2BNiP, Popcorn Hour C-200...) laying around, which I like to use with Spotify. When it works, it works perfectly, especially with the Sony system. However, there are several issues, which suspectedly come from the fact that I installed it on my Synology DS220j NAS. I run the spotupnp-linux-arm-static version, which basically works. I also managed to run it as a service, as described in the readme. I have created a config file with sections for each device. However, it seems that data is always sent as raw PCM, no matter which option I choose in the config file. Am I right in assuming that for using MP3 etc. an encoder needs to be installed on the NAS? In addition, after working for a while it just crashes in the middle of a song. Playback just stops on the stereo without stopping in Spotify itself. The device still appears in the app but it doesn't connect anymore to the stereo. Restarting the service helps. Furthermore, when a device is selected in the Spotify app, it instantaneously starts playing the last song. This behaviour is different from devices that natively support Spotify connect. Is there a way to change this, so that the device is just selected without directly starting to playback? Thanks in advance for any hints.

philippe44 commented 6 months ago

It is not needed to install a codec, they are all boult-in so mp3 should work out of the box. Can you share your config file? Re immediate start, it's a cspot "feature" that've not changed but there is no way around

spotuser commented 6 months ago

Sure I'd like to share the file, just struggling with inserting the formatted text here, it seems to be interpreted as code and messes up the whole message.

For the Poppi (Popcorn Hour C-200), this is the only way it works at all; however, it only works for one track, then it completely stops. The Sony stereo indicates the format in its display and it this always "PCM". When playing a normal MP3 Track from the NAS it is "MP3". Thanks for your support, greatly appreciated.

spotuser commented 6 months ago
<?xml version="1.0"?>
<spotupnp>
<common>
<protocolInfo></protocolInfo>
<enabled>1</enabled>
<max_volume>100</max_volume>
<http_content_length>-3</http_content_length>
<upnp_max>1</upnp_max>
<codec>wav</codec>
<vorbis_rate>320</vorbis_rate>
<flow>0</flow>
<use_filecache>0</use_filecache>
<gapless>1</gapless>
<artwork></artwork>
</common>
<main_log>info</main_log>
<upnp_log>info</upnp_log>
<util_log>warn</util_log>
<log_limit>-1</log_limit>
<max_players>32</max_players>
<interface>?</interface>
<credentials_path>/volume1/Daten/SpotUPnP/credentials/</credentials_path>
<credentials>0</credentials>
<ports>0:0</ports>

<device>
<udn>uuid:54998793-37ab-49d1-9cd7-ACA2134408F1</udn>
<credentials></credentials>
<name>Internetradio+</name>
<max_volume>100</max_volume>
<mac>DELETED</mac>
<enabled>1</enabled>
</device>

<device>
<udn>uuid:9C75C70E-D29F-4EF5-B29D-57A151213CF3</udn>
<credentials></credentials>
<name>Poppi+</name>
<max_volume>50</max_volume>
<mac>DELETED</mac>
<http_content_length>0</http_content_length>
<upnp_max>1</upnp_max>
<codec>wav</codec>
<use_filecache>1</use_filecache>
<flow>0</flow>
<enabled>1</enabled>
</device>

<device>
<udn>uuid:7b1afe95-d1b8-3c6b-f430-e7e5db4101dc</udn>
<credentials></credentials>
<name>Surface+</name>
<mac>bb:bb:be:13:c5:90</mac>
<enabled>1</enabled>
</device>

<device>
<udn>uuid:5f9ec1b3-ed59-1900-4530-3c07717ccf80</udn>
<credentials></credentials>
<name>CMT-G2BNiP+</name>
<mac>DELETED</mac>
<codec>mp3:320</codec>
<gapless>1</gapless>
<enabled>1</enabled>
</device>
philippe44 commented 6 months ago

GitHub has the option to link a file, not copy/paste text

spotuser commented 6 months ago

Yes, but unfortunately it seems not to be possible to attach an .xml file...hence I renamed it to config.txt.

config.txt

philippe44 commented 6 months ago

Codec is set to wav for that player, so obviously it will be pcm. You have also set http_content_length to 0 which is not ideal for gapless playback

spotuser commented 6 months ago

For the Poppi (Popcorn Hour C-200), setting it to wav and http_content_length=0 is the only way it works at all; however, it only works for one track, then it completely stops.

The Sony (last entry) is set to mp3:320. It indicates the format in its display and it this always "PCM". When playing a normal MP3 Track from the NAS it is "MP3".

philippe44 commented 6 months ago
philippe44 commented 6 months ago

Otherwise try to ignore the config file (just rename it) and only use command line to set codec for all.

spotuser commented 6 months ago

Ok, I can do that. So that means, I rename the file, start spotupnp again with -d all=debug. Then I start playing something on the Sony. But how can I set the codec at the command line then?

philippe44 commented 6 months ago

I'm not in front of a computer but just type -h and all the options will be displayed

spotuser commented 6 months ago

Ok, so I just startet with -d all=debug, still keeping the current config file. I tried playing on the Sony. First, when I hit play on the Spotify app, it started playing, but not the Spotify song but the first song from my Server. This also happens once in a while. I am still running spotupnp, how can I save the logfile now? Or is it automatically created once I exit the program?

philippe44 commented 6 months ago

No it's created if you use -f or redirect stderr to a file

spotuser commented 6 months ago

Ok, I redirected the output into a textfile, which is attached. The behavior was the same: It did not play the Spotify song but the first MP3 from my Server. logfile.txt

philippe44 commented 6 months ago

Unfortunately this is not the whole file, better use -f

spotuser commented 6 months ago

This one was created using -f now. Same behavior. logfile.txt

philippe44 commented 6 months ago

And this one still says pcm? Because it's mp3 being sent

spotuser commented 6 months ago

No, it did't play from Spotify at all. Started playing one of my local Mp3 files though in the Spotify app it seemed to play Spotify.

Tried suspending/renaming the config file and using command line parameter -c as well. When specifying mp3 it didn't work. When using wav as parameter it worked again.

The behavior is strange, because the Sony is otherwise obviously capable of playing MP3

philippe44 commented 6 months ago

Sorry this is becoming pretty confusing. Please rename the config file, use command line (I think it's -c mp3), play from Spotify (desktop or Android/iOS) and post the log.

spotuser commented 6 months ago

I will do so tomorrow, today unfortunately I won't manage anymore. Huge thanks for the support so far.

spotuser commented 6 months ago

Good morning, ok, I think part of the confusion was caused by me. When the Sony was displaying PCM, this was always when WAV was selected as codec (no matter if through config file or command line). Apologies for that.

The major problem is, however, that MP3 as codec doesn't seem to work on my devices. I did as you said in your last post: rename the config file and specify -c mp3:320 in debug mode. The logfile is attached.

The Sony stereo started playing the first MP3 file from my NAS, while the Spotify app on my phone showed it as playing from Spotify. To me, it seems that the Sony is receiving the play command but not the Spotify file. logfile.txt

philippe44 commented 6 months ago

The Sony stereo started playing the first MP3 file from my NAS, while the Spotify app on my phone showed it as playing from Spotify. logfile.txt

I'm sorry but I really don't understand that sentence (and the log does not show anything playing). This is a Spotify bridge, so you don't play anything from your NAS, you play from Spotify. Playback files are remote, on Spotify servers, never from your local storage.

The purpose of SpotUPnP is to mimic a Spotify Connect device for every UPnP player you have. That "mimic-ed" player receives tracks in Vorbis format (Spotify default), decode them, encode them back (mp3, flac, wav, raw pcm, aac, opus, vorbis.) before sending them to your real UPnP player. Is this what you are looking for?

spotuser commented 6 months ago

The Sony stereo started playing the first MP3 file from my NAS, while the Spotify app on my phone showed it as playing from Spotify. logfile.txt

I'm sorry but I really don't understand that sentence (and the log does not show anything playing). This is a Spotify bridge, so you don't play anything from your NAS, you play from Spotify. Playback files are remote, on Spotify servers, never from your local storage.

This is just exactly what happened...I hit play in Spotify and the stereo did not (as expected) start playing the Spotify song but the first song from the NAS (in alphabetical order). I know that this is a very strange behavior, but it only happens, when MP3 is selected as codec (via command line or config file). It is also strange that the log seems not to show anything playing.

The purpose of SpotUPnP is to mimic a Spotify Connect device for every UPnP player you have. That "mimic-ed" player receives tracks in Vorbis format (Spotify default), decode them, encode them back (mp3, flac, wav, raw pcm, aac, opus, vorbis.) before sending them to your real UPnP player. Is this what you are looking for?

Yes, this is exactly what I need and, as mentioned, when it works, it works like a charm :) However, it only works when selecting WAV as codec (although the renderer supports MP3) and even then it crashes once in a while in the middle of a song (as mentioned).

spotuser commented 6 months ago

add: Other codecs, such as FLAC do also not work, although the stereo should be able to play them. I also tried an iTuner 320 and it did also not play when MP3 was selected as codec...

philippe44 commented 6 months ago

The log definitively shows no command or request being sent to the player. I think there is something else interfering in your system. Are you 10000% sure there is no other instance of spotupnp running somewhere in your network? That's has to be the only rationale explanation

spotuser commented 6 months ago

There is no other instance of spotupnp in the network, I am sure about that. I also tried running it on my Macbook (while having the other one disabled), same behavior.

For the time being, since the Sony stereo also supports Airplay, I have switched to spotraop.

But still it is strange that using MP3 or FLAC with spotupnp doesnt seem to work with my devices. I am wondering whether anyone else experienced these issues. It might well be that it is something else in my network, but besides the Synology I am not running any other Server.

philippe44 commented 6 months ago

I have not heard about such issue now but what is really weird is that no UPnP play command is sent to your player by spotupnp. The fact that it plays something from your NAS is because it receives a play command with no content so it plays the last uri that it was given to it, by some other controller.

spotuser commented 6 months ago

The fact that it plays something for your NAS is because it receives a play command with no content so it plays the last uri that it was given to it, by some other controller.

Yes, I was also suspecting that.

I have not heard about such issue now but what is really weird is that no UPnP play command is sent to your player by spotupnp.

Could it be somehow related to ports? Does DLNA require certain ports to be forwarded? Would also be weird because WAV works and MP3 doesn't but just in case...

Using audio station on the Synology, I can flawlessly stream MP3s vial DLNA to the Sony stereo...