Hifiberry OSでSpotifiyに接続できない。あるいはすぐ切れる

投稿者: | 5月 4, 2025

オーディオを整理中。片付けているのではなく、動くものは設置(いかんせん、一人暮らし一軒家になってしまったので場所はある。)、壊れているものは修理。なんていうことをしている。壊れているものが手強い。複数の機材で構成されていると、どれが壊れているのかを調べる、じゃなくて気が付くのが大変。アンプが調子悪いと思ったら、外部出力をするために、TAPE OUTを使っていたのだが、どうやらそのスイッチがおかしいのに気が付かず、別のアンプの中身を調べたり。。。

今時、TAPE OUTなんて使っている人いないでしょ、ダビングやエアチェックする人なんていないので。(死語のオンパレード。知らなくても困らない。)

そういう意味では、Hifiberry OSも使っている人はどれだけいるのか?どうやらHifiberry OSの開発は、一旦やめにして、Raspberry PI OSのアドオンにする様子。コンパクトなOSではなくなりそう。Hifiberry OSは、Dockerでモジュールを追加できたので、便利だと思ったんだが。

 

閑話休題

 

Hifiberry OSでSpotifyが繋がらなかったり、繋がってもすぐ切れてしまったり。なかなか安定しない。理由がわかった。

vi /etc/hosts

これが原因らしい。

104.199.65.124 ap-gew4.spotify.com

nslookupで調べてみると

nslookup ap-gew4.spotify.com

Server: 127.0.0.53

Address: 127.0.0.53#53

 

Non-authoritative answer:

Name: ap-gew4.spotify.com

Address: 34.158.1.133

 

さらに以下でもIPが固定されている。

https://github.com/hifiberry/hifiberry-os/blob/master/buildroot/package/vollibrespot/vollibrespot.service

ExecStartPre=/opt/hifiberry/bin/store-volume /tmp/spotifyvol

ExecStartPre=/opt/hifiberry/bin/set-host-ip ap-gew4.spotify.com 104.199.65.124

ExecStart=/usr/bin/vollibrespot -c /etc/vollibrespot.conf

なんだ?この 104.199.65.124 ap-gew4.spotify.com

開発元では

HiFiBerry teamSeptember 13, 2024 at 12:59 AM

We do ot plan any new 32bit releases.Our development efforts go into the new 64bit version. However, feel free to edit /etc/host. 

And yes: There is a reason for hardcoding the IP in /etc/hosts: It was necessary to make Spotify work for some people. So even if it works better for you without this, doesn’t mean, it’s the best way for everyone. Spotify seems to use different connfigurations in different parts of the world.

とあり、どこかの人では必要な設定らしい。

 

どうやら国ごとに設定が違うらしい。

https://community.spotify.com/t5/Other-Podcasts-Partners-etc/No-music-when-using-Spotty-in-Denmark/td-p/5349988

一部の地域では、この設定がいる様子。この例だとデンマークとか。ただし、日本だと要らない。

/etc/hostsと/usr/lib/systemd/system/spotify.serviceの該当行をコメントアウトするか削除する必要がある。

sshでログインをして

削除するなら

sed -i '/ap-gew4.spotify.com/d' /usr/lib/systemd/system/spotify.service
sed -i '/ap-gew4.spotify.com/d' /etc/hosts
reboot

コメントアウトするなら

sed -i '/ap-gew4\.spotify\.com/ s/^/#/' /usr/lib/systemd/system/spotify.service
sed -i '/ap-gew4\.spotify\.com/ s/^/#/' /etc/hosts
reboot

とすればOK。

あとは、起動時にボリュームが50%になってしまうのをどうにかしないと。デジタルの出力なんて、ボリュームを下げる意味ないと思う。アナログ部分で下げればいい。

とりあえず、これを書いている間は、Spotifiyはちゃんとリダイレクトできている。

 

ボリュームが50%になってしまうのは、AirplayとSpotifyのOSやアプリのボリュームを上がいてしまうからだったことが判明。つまり、OSやアプリでボリュームを上げろと。確かに連動している。Hifiberry OSのUIを開く必要はなかったわ。

https://support.hifiberry.com/hc/en-us/community/posts/22256354896797-How-to-set-default-volume-Spotify-and-Airplay-to-max

コメントを残す