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

Discussion in 'Nguồn phát từ máy tính' started by tml3nr, 6/6/18.

  1. tml3nr

    tml3nr Advanced Member

    Joined:
    30/4/07
    Messages:
    3.082
    Likes Received:
    3.514
    60k một tháng dùng cũng xứng đáng lắm anh ạ. Nó tiện. Nhất là cơ chế gợi ý, liên kết nhạc của nó rất hay.

    Lúc trước em setup NAS để nghe nhạc Flac qua internet. Sử dụng rất OK nhưng lợi bất cập hại vì tốn dung lượng 3G nhiều quá :D
     
    viking and tieuphi2006 like this.
  2. Hagemi

    Hagemi Advanced Member

    Joined:
    4/8/16
    Messages:
    223
    Likes Received:
    658
    Spotify chạy trên pi2 ngon lành chứ bác @tml3nr nhỉ? Chạy trên rune, moodle hay volumino cho kết quả tốt nhất hả bác
     
    tml3nr likes this.
  3. tml3nr

    tml3nr Advanced Member

    Joined:
    30/4/07
    Messages:
    3.082
    Likes Received:
    3.514
    Chạy trên pi2 ngon ạ. Em thích dùng pi2 hơn vì nó ít noise.

    Nó chạy tốt trên cả 3 OS. Anh thích dùng cái nào cũng được.
     
    Hagemi likes this.
  4. Hagemi

    Hagemi Advanced Member

    Joined:
    4/8/16
    Messages:
    223
    Likes Received:
    658
    Bản rune này là đã làm sẵn spotify rồi bác nhỉ. Chỉ cần cào rune bật lên là ok phải ko ạ?
    Thấy bác vẫn trung thành với rune từ đầu đến giờ, chắc phải có lý do nhỉ :)
     
    tieuphi2006 and tml3nr like this.
  5. tml3nr

    tml3nr Advanced Member

    Joined:
    30/4/07
    Messages:
    3.082
    Likes Received:
    3.514
    Anh dùng bản Rune "hết số" này của em cũng được. Em o bế kỹ hơn các bản trước.

    Spotify chỉ cần làm thêm 3 bước nữa là dùng được.

    Không hiểu sao đồ và tai của em hợp với rune nhất. Chạy loanh quanh rồi cũng quay về nó.

     
    Hagemi likes this.
  6. tml3nr

    tml3nr Advanced Member

    Joined:
    30/4/07
    Messages:
    3.082
    Likes Received:
    3.514
    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 kiểu 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-02-25-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

    Code:
    [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

    Code:
    [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:

    Code:
    systemctl start spotifyd
    Code:
    systemctl enable spotifyd
    Xem thông tin hoạt động của Spotifyd:

    Code:
    systemctl status spotifyd
    Vậy là xong ạ!

    More information:

    https://github.com/Spotifyd/spotifyd/wiki/Installing-on-a-Raspberry-Pi
     
    Last edited: 23/4/19
    TQ_Audio likes this.
  7. tml3nr

    tml3nr Advanced Member

    Joined:
    30/4/07
    Messages:
    3.082
    Likes Received:
    3.514
    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...

    Code:
    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

    Code:
    #!/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:

    Code:
    [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
    
    Code:
    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.
     
    Last edited: 19/5/19
    TQ_Audio and Hagemi like this.
  8. tathien

    tathien New Member

    Joined:
    28/2/16
    Messages:
    1
    Likes Received:
    1
    Bác tml3nr có online không ?
     
    tml3nr likes this.
Tags:

Share This Page

Loading...