Chia sẻ một vài cách setup Spotify Connect trên Raspberry Pi (Cập nhật lần 2)

Thangbandia69

New Member
Cảm ơn anh @tml3nr hôm qua xà quần mãi mới thanh công anh ạ', cái chỗ Mixer của em phải thay bằng Mixer_type = none thì mới được.... Cảm ơn anh nghe hay hơn bản spotify của moOde gốc anh ạ...
 

tml3nr

Moderator
Em mò ra được một cách cải thiện âm thanh của SC spotifyd rất đáng kể ạ.

Khi mình play Spotify, nó sẽ tự động stop các dịch vụ khác. Khi stop Spotify nó sẽ start lại như cũ.

Mình có thể dùng cách này để stop mpd, upmpdcli, airplay...

Mã:
root@runeaudio(rw):~# spotifyd --help
Usage: spotifyd [options]

Options:
  -c, --config CONFIG Path to a config file.
  -u, --username USERNAME
  Spotify user name.
  -p, --password PASSWORD
  Spotify password.
  --device DEVICE Audio device, given by aplay -L.
  --mixer DEVICE  Audio mixer
  --bitrate DEVICE
  Any of 96, 160, and 320.
  --pid PID-FILE  Path to PID file.
  --device_name DEVICE
  Name of this Spotify device.
  --backend BACKEND
  Audio backend.
  --cache_path PATH
  Path to cache location.
  --volume-normalisation
  Apply volume normalisation per track.
  --normalisation-pregain PREGAIN
  dB of pregain for volume normalisation
  --onevent COMMAND
  Run a command on events. Environment variables
  PLAYER_EVENT, TRACK_ID,OLD_TRACK_ID are passed to the
  command.
  --volume-control CONTROLLER
  Possible values are alsa, alsa_linear, and softvol.
  -v, --verbose  Add debug information to log.
  --no-daemon  Don't detach from console.
  --backends  List available audio backends.
  -h, --help  Print this help text.

Tạo file spotifyd_even.sh. Set chmod 755:

nano /home/root/spotifyd_event.sh

Mã:
#!/bin/bash

case "$PLAYER_EVENT" in

  start)
   # Stop mpd
   systemctl stop mpd
   exit
   ;;

  stop)
   # Start mpd
   systemctl start mpd
   exit
   ;;
esac
exit 0

Edit spotifyd.service:

Mã:
[Unit]
Description=A spotify playing daemon
Documentation=https://github.com/Spotifyd/spotifyd
Wants=sound.target
After=sound.target
Wants=network-online.target
After=network-online.target

[Service]
ExecStart=/usr/bin/spotifyd --no-daemon --onevent /home/root/spotifyd_event.sh
Restart=always
RestartSec=12

[Install]
WantedBy=default.target

Mã:
systemctl daemon-reload
systemctl stop spotifyd
systemctl start spotifyd

Vậy là xong ạ!

@@@ Lưu ý:

Một vài OS sau khi restart service. Có thể cần phải start lại script optimize để áp các settings priority cho service.
 
Chỉnh sửa lần cuối:

thebluewindows

Well-Known Member
Spotifyd của em đồng bộ tốt volume với boss dac ạ. Em dùng:

mixer = Digital
Cũng set vậy mà chỉnh volume trên Spotify ngó sang Moode ko thấy nó nhúc nhắc volume :confused:
P/S: Xem lại alsa volume thấy đồng bộ rùi. Tại trên giao diện player nó cứ trơ ra làm e nghĩ nhầm :oops:
 
Chỉnh sửa lần cuối:

tml3nr

Moderator
Cũng set vậy mà chỉnh volume trên Spotify ngó sang Moode ko thấy nó nhúc nhắc volume :confused:
P/S: Xem lại alsa volume thấy đồng bộ rùi. Tại trên giao diện player nó cứ trơ ra làm e nghĩ nhầm :oops:
Dạ đúng như vậy ạ. moode từ tước tới giờ không cập nhật volume trên webui khi alsa thay đổi.

Kéo volume trên webui thì nó kéo theo volume alsa. Nhưng ngược lại thì không.

spotifyd này tiếng hay quá anh nhỉ? Trong trẻo, sạch sẽ và airy tốt ghê. Em thấy trong tất cả các kiểu SC tiếng của nó hay nhất :rolleyes:
 

chuong46

Active Member
@tml3nr : Xà quần 2 ngày mà chưa cài được Spotifyd, bạn giúp hướng dẫn chi tiết từng lệnh và cách cài để copy và paste. Cài trên pi3B - allo digione - moodeaudio 3.8.4
Thanks.
 

tml3nr

Moderator
@tml3nr : Xà quần 2 ngày mà chưa cài được Spotifyd, bạn giúp hướng dẫn chi tiết từng lệnh và cách cài để copy và paste. Cài trên pi3B - allo digione - moodeaudio 3.8.4
Thanks.
Anh đang vướng chổ nào ạ? Anh xem kỹ bài này:

http://www.hdvietnam.com/posts/10019230/

Khó chịu nhất là khai báo dòng device và mixer trong file spotifyd.conf:

device = xxx # Given by `aplay -L`
mixer = xxx

Nếu dùng digione anh chọn mixer_type = none như bài bên dưới:

Cảm ơn anh @tml3nr hôm qua xà quần mãi mới thanh công anh ạ', cái chỗ Mixer của em phải thay bằng Mixer_type = none thì mới được.... Cảm ơn anh nghe hay hơn bản spotify của moOde gốc anh ạ...

Theo em nên test các bản spotifyd-xxx-armv6-slim trước và nên test các bản cũ trước.

Em thấy các bản trước ver 0.2.12 có vẻ dễ chịu hơn.

https://github.com/Spotifyd/spotifyd/releases/download/0.2.12/spotifyd-2019-09-15-armv6-slim.zip
 
Chỉnh sửa lần cuối:

chuong46

Active Member
@tml3nr : Mình làm theo http://www.hdvietnam.com/posts/10019230/, đã kết nối và nghe OK nhưng chạy mấy lệnh ở Bước 4 không được, chỉ chạy được lệnh "systemctl --user start spotifyd.service" còn 2 lệnh này: "sudo loginctl enable-linger <username>" và "systemctl --user enable spotifyd.service" báo lỗi nên khi thoát màn hình Putty là ngắt luôn Spotìyd. mình cài Spotifyd bản mới nhất.
 

tml3nr

Moderator
@tml3nr : Mình làm theo http://www.hdvietnam.com/posts/10019230/, đã kết nối và nghe OK nhưng chạy mấy lệnh ở Bước 4 không được, chỉ chạy được lệnh "systemctl --user start spotifyd.service" còn 2 lệnh này: "sudo loginctl enable-linger <username>" và "systemctl --user enable spotifyd.service" báo lỗi nên khi thoát màn hình Putty là ngắt luôn Spotìyd. mình cài Spotifyd bản mới nhất.
Éc éc, hình như anh lộn sang tuồng khác rồi :eek:

Nhờ anh tây dynobot chỉ đường. Em mò ra được thêm một cách tạo SC rất đơn giản. Âm thanh theo em là hay nhất trong tất cả các loại SC từ trước đến giờ. Đồng bộ được với volume của alsa.

Em chỉ mới test trên Rune. Chắc là sẽ OK trên các OS khác.

Bước 1:

https://github.com/Spotifyd/spotifyd/releases/

Download file spotifyd-2019-xx-xx-armv6.zip. Extract file spotifyd vào /usr/bin. Rồi set:

chmod +x /usr/bin/spotifyd

Bước 2 - Tạo file config:

nano /etc/spotifyd.conf

Mã:
[global]
username = your_account
password = your_password
backend = alsa
device = xxx # Given by `aplay -L`
mixer = xxx
volume-control = alsa # or alsa_linear, or softvol
#onevent = command_run_on_playback_event
device_name = RuneAudio
bitrate = 320
#cache_path = /tmp/spotifyd
volume-normalisation = false
#normalisation-pregain = -10

Ghi chú:

device = xxx # Lấy theo device của alsa. Thí dụ: hw:0
mixer = xxx # Lấy theo PCM, hay Digital của alsa
device_name = Tùy chọn. Không được có khoảng trắng.

Bước 3 - Tạo file service:

- Rune:

nano /usr/lib/systemd/system/spotifyd.service

- moode / volumio:

nano /lib/systemd/system/spotifyd.service

Mã:
[Unit]
Description=A spotify playing daemon
Documentation=https://github.com/Spotifyd/spotifyd
Wants=sound.target
After=sound.target
Wants=network-online.target
After=network-online.target

[Service]
ExecStart=/usr/bin/spotifyd --no-daemon
Restart=always
RestartSec=12

[Install]
WantedBy=default.target

Bước 4:

Mã:
systemctl start spotifyd

Mã:
systemctl enable spotifyd

Xem thông tin hoạt động của Spotifyd:

Mã:
systemctl status spotifyd

Ghi chú: Trước khi edit ta cần phải stop service:

Mã:
systemctl stop spotifyd

Vậy là xong ạ!

More information:

https://github.com/Spotifyd/spotifyd/wiki/Installing-on-a-Raspberry-Pi
 

chuong46

Active Member
@tml3nr : Được rồi bạn, cài bản V0.2.12 bạn chỉ đã OK (Tạo file service: thay "
sudo nano /lib/systemd/system/spotifyd.service" bằng "sudo nano /etc/systemd/user/spotifyd.service"; các lệnh khác thêm "Sudo" vào trước). Bạn hướng dẫn thêm về tắt các servicer khác khi nghe Spotify với Moode 3.8.4
 

tml3nr

Moderator
Bên trên