[數位音樂] Listen Spotify and Use Snapcast 實現多空間音樂聆聽 (Server 端)

昨天那篇,如果是很單純只想聽 Spotify Premium,然後又不想只是切換到其中一個裝置,其實有比較簡單的解法。

只要使用 librespot 的 pipe backend 配合 Snapcast 即可。

一、Build librespot (Ubuntu)

Udoo X86 use Ubuntu 17.04 (Zesty Zapus)

先裝 Rust 編譯環境

curl https://sh.rustup.rs -sSf " sh

裝相依的 library

sudo apt update
sudo apt install build-essential portaudio19-dev

Clone 專案並編譯

git clone https://github.com/plietar/librespot.git
cd librespot
export PATH=$HOME/.cargo/bin:$PATH
cargo build --release

然後把編譯好的 librespot 執行檔放到 /usr/local/bin 去

sudo cp target/release/librespot /usr/local/bin/

二、Install Snapcast (Ubuntu)

Download From: https://github.com/badaix/snapcast/releases/latest

image-8

Get snapserver_0.11.1_amd64.deb

wget https://github.com/badaix/snapcast/releases/download/v0.11.1/snapserver_0.11.1_amd64.deb
dpkg -i snapserver_0.11.1_amd64.deb

三、Edit Snapcast Config file

sudo vi /etc/default/snapserver

START_SNAPSERVER=true
USER_OPTS="--user snapserver:snapserver"
SNAPSERVER_OPTS="-d -s spotify:///librespot?name=Spotify&username=YOURUSERNAME&password=YOURPASSWORD&devicename=Snapcast&bitrate=320"

四、服務重啟

sudo service snapserver restart

這樣你打開你的 Spotify Player,可以多看到一個叫做 Snapcast 的裝置,選擇他就會播放到 Snapcast Server 去,之後再透過其他台 Snapcast Client 就可以實現 Spotify 多空間同步音樂聆聽。

像下圖這樣

img-alternative-text

參考:
librespot
snapcast

留言

這個網誌中的熱門文章

有點誇張的準專業機.Minolta Alpha 7 (Dynax 7、Maxxum 7).2000

在 Excel 裡轉換 Unixtime 格式

Lightroom.製作並匯出 Preset