Chia sẻ một cách setup Spotify Connect trên RuneAudio

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

  1. tml3nr

    tml3nr Advanced Member

    Joined:
    30/4/07
    Messages:
    3.082
    Likes Received:
    3.514
    Anh cài theo cách nào và lên OS nào ạ? Có vẻ như anh chưa tạo file service để nó tự động chạy khi mình khởi động lại OS.

    Nếu anh làm không được em sẽ teamviewer làm cho anh.
     
  2. hn1804

    hn1804 Advanced Member

    Joined:
    29/2/16
    Messages:
    571
    Likes Received:
    605
    Đánh lệnh : systemctl enable spotify-connect
    Xong sau đó mình tắt puty và khởi động lại pi .
    Khi hoàn tất cài đặt thì ta save và thoát khỏi puty có cần đánh lệnh gì không vì mình thấy lúc nào tắt puty nó cũng báo dòng gì đấy
     
  3. tml3nr

    tml3nr Advanced Member

    Joined:
    30/4/07
    Messages:
    3.082
    Likes Received:
    3.514
    Anh gõ exit để thoát khỏi putty ạ.
     
    hn1804 likes this.
  4. hn1804

    hn1804 Advanced Member

    Joined:
    29/2/16
    Messages:
    571
    Likes Received:
    605
    Mình cài spotify lại hát ngon lành chỉ có điều nó không hiển thị lên pi2 bác ạ .
    0BAE9875-11B4-49D1-9EEC-C708357A7F1F.jpeg CB3ADFD7-45B4-4587-AEAF-BE15429DCEBE.png
     
  5. tml3nr

    tml3nr Advanced Member

    Joined:
    30/4/07
    Messages:
    3.082
    Likes Received:
    3.514
    Nó hiện như vậy là đang phát airplay chứ không phải Spotify connect ạ. (Mình phải có acc premium mới dùng được SC)

    Như hình này là đang phát qua SC:

    [​IMG]
     

    Attached Files:

    Last edited: 29/4/18
  6. hn1804

    hn1804 Advanced Member

    Joined:
    29/2/16
    Messages:
    571
    Likes Received:
    605
    Em co acc rồi nhưng không stream dc .
    D9926A20-8151-4BDA-ACCB-0CAC72B0A66A.png CA3AFB2B-76DD-41A3-9CB0-57C46BE45A8A.jpeg
    4593943A-3E21-433C-9B41-87BD06ADF9E9.png
    F690D75B-7B65-4B90-9CAB-9DA8FFDDB3B6.png
     
    Last edited: 29/4/18
  7. tml3nr

    tml3nr Advanced Member

    Joined:
    30/4/07
    Messages:
    3.082
    Likes Received:
    3.514
    Cách như hình bên dưới là Spotify client. Nó chỉ play được cái playlist mình làm sẵn.

    Cách Spotify Connect mình có thể định cho Rune phát nhạc từ một app hay web đang chạy Spotify.

    [​IMG]
     
    Last edited: 29/4/18
  8. hn1804

    hn1804 Advanced Member

    Joined:
    29/2/16
    Messages:
    571
    Likes Received:
    605
    Để mình đọc kỷ lại và làm lại xem sao
     

    Attached Files:

    Last edited: 29/4/18
  9. tml3nr

    tml3nr Advanced Member

    Joined:
    30/4/07
    Messages:
    3.082
    Likes Received:
    3.514
    Em vô teamview không được ạ?
     
  10. hn1804

    hn1804 Advanced Member

    Joined:
    29/2/16
    Messages:
    571
    Likes Received:
    605
    Số dt của em : 0904699488 , gọi em em đọc đi và pass cho
     
  11. hn1804

    hn1804 Advanced Member

    Joined:
    29/2/16
    Messages:
    571
    Likes Received:
    605
    Cám ơn Hải rất nhiều , đã nghe ngon lành rồi , nhưng cho anh hỏi thêm có nên bậc airplay và spotify trong rune cùng lúc không . Vì lúc nãy anh có chỉnh thì bị lỗi , sau đó tắt spotify chỉ để AirPlay lại thì không sao
     
  12. tml3nr

    tml3nr Advanced Member

    Joined:
    30/4/07
    Messages:
    3.082
    Likes Received:
    3.514
    Theo em thấy thì khi mình bật AirPlay âm thanh khi nghe MPD có mờ đi một ít. Nếu bật UPnP tiếng mờ hơn là bật AirPlay.

    Nếu không dùng AirPlay mình tắt luôn là tốt nhất.

    Em chỉ dùng AirPlay để phát nhạc Youtube từ iPad (Bằng app musi). Cũng vui vui.

    Cái tút Spotify Connect này em có post trên forum Rune. Có một anh Tây nói là chạy trên Pi3 / USB Dac vài hôm thì bị mất tiếng. Trên Pi2 em chạy tới nay gần 1 tháng chưa thấy gì bất thường (Chạy chung với AirPlay). Em cũng không rõ thế nào.

    Mấy cái OS dạng này mình chịu cực tí. Lọ mọ xoay trở cũng OK thôi anh ạ.

    Em highly recommend Pi2. Nó lợi nhiều thứ lắm :D
     
    hn1804 likes this.
  13. hn1804

    hn1804 Advanced Member

    Joined:
    29/2/16
    Messages:
    571
    Likes Received:
    605
    Cái vụ spotify airplay và spotify connect kể cả uPnP nghe trên app hay web streaming qua pi3 em đã chỉnh dc và chơi tất cả 3 ứng dụng trên cùng rune .
    Trong setting / airplay name và uPnP name đổi tên trùng với tên của spotify connect là RuneAudio / reboot. Ok
    Lúc trước khi cài mặc định trên của
    Spotify connect : RuneAudio
    Spotify Airplay : RuneAudio (AirPlay)
    uPnP. : RuneAudio (uPnP)

    01A7339C-A6AB-4614-9E2D-D2791EC66356.png BE158C3E-FF0A-477C-A734-C64BF171C455.png 13056F6D-6EC2-45C1-8079-A7B19FE5B8C8.png
     
    Last edited: 30/4/18
    tml3nr likes this.
  14. hn1804

    hn1804 Advanced Member

    Joined:
    29/2/16
    Messages:
    571
    Likes Received:
    605
    Lưu ý các bác để chuyển chế độ phát giữa nghe trên phone hay nghe stream qua spotify-airplay, spotify-connect các bác phải ấn nút pause tạm dừng nghe sau đó chỉnh chế độ nghe sau đó ấn play lại , nếu chỉnh chế độ trong lúc đang phát nhạc sẽ xảy ra hiện tượng mất tiếng , không phát qua spotify-airplay dc .
     
  15. tml3nr

    tml3nr Advanced Member

    Joined:
    30/4/07
    Messages:
    3.082
    Likes Received:
    3.514
    Cài Spotify Connect (SC) powerpi.de trên moode 4.1:

    Ngoài cách dùng SC Raspotify, ta có thể cài SC theo cách của bài đầu tiên lên moode. Theo em cách này có ưu điểm là khi mình kéo volume của app nó kéo theo được volume của alsamixer digital. Rất tiện cho anh nào dùng hardware volume... như em :rolleyes:

    Cách làm tương tự như bài 1 của thread này. Chỉ khác một chút là cần tạo folder /home/root và sửa file spotify-connect-web.sh và file spotify-connect.service.

    Trước tiên ta cần phải extend partition cho thẻ nhớ.

    sudo mkdir /home/root

    cd /home/root

    Bước 1, putty:

    Code:
    curl -O http://spotify-connect-web.s3-website.eu-central-1.amazonaws.com/spotify-connect-web.sh
    Bước 2, edit file /home/root/spotify-connect-web.sh. (Dùng lệnh: nano /home/root/spotify-connect-web.sh hoặc edit bằng WinSCP). Kết quả sẽ giống như sau:

    Code:
    #!/bin/bash
    set -e
    
    DIR=/home/root/spotify-connect-web-chroot
    
    if [ "$1" == "install" ]; then
      mkdir -p $DIR
      cd $DIR
      curl http://spotify-connect-web.s3-website.eu-central-1.amazonaws.com/spotify-connect-web.tar.gz | tar xz
    else
      trap "sudo umount $DIR/dev $DIR/proc" EXIT
      sudo mount --bind /dev $DIR/dev
      sudo mount -t proc proc $DIR/proc/
       sudo cp /etc/resolv.conf $DIR/etc/
      sudo chroot $DIR /bin/bash -c "cd /usr/src/app && python main.py $*"
    fi
    Bước 3, putty. Run:

    Code:
    sudo chmod +x spotify-connect-web.sh
    Code:
    sudo ./spotify-connect-web.sh install
    Bước 4, WinSCP:

    copy file spotify_appkey.key trong file nén bên dưới vào /home/root/spotify-connect-web-chroot/usr/src/app

    copy overwrite file console_callbacks.py trong file nén vào /home/root/spotify-connect-web-chroot/usr/src/app

    Bước 5, putty. Run test:

    Code:
    /home/root/spotify-connect-web.sh --name moOde --device 0 --mixer Digital --username abc --password xyz --bitrate 320
    Giá trị của --device và --mixer mình dựa theo alsamixer, như hình bên dưới. User và pass là account thật.

    --mixer Analogue hay Digital tùy theo Dac. Nếu là Boss Dac mình chọn Digital.

    Khi mình chỉnh volume trong app / web Spotify. Nó kéo theo được volume của alsamixer!

    [​IMG]

    Nếu OK mình sẽ thấy như sau, thời điểm này Spotify Connect đã hoạt động:

    Code:
    SpInit: 0
    public key: Xwj3zMW9xxxxxxxxxxxxxxxxxxxxxx
    device id: 43a952b7-a8cb-xxxxxxxxxxxxxxxxxxxx
    remote name: moOde
    account req: PREMIUM
    device type: AUDIODONGLE
    kSpConnectionNotifyLoggedIn
    F6hvzT7Hudsxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
    Bước 6: putty. Tạo file service:

    Code:
    sudo nano /lib/systemd/system/spotify-connect.service
    Chứa nội dung sau. User và pass là account thật.

    Code:
    [Unit]
    Description=Spotify Connect
    After=network.target
    
    [Service]
    ExecStart=/home/root/spotify-connect-web.sh --name moOde --device 0 --mixer Digital --username abc --password xyz --bitrate 320
    Restart=always
    RestartSec=10
    StartLimitInterval=30
    StartLimitBurst=20
    
    [Install]
    WantedBy=multi-user.target
    Bước 7, putty. Set cho service auto start:

    Code:
    sudo systemctl enable spotify-connect
    Vậy là xong ạ!

    Download file spotify_appkey.key và console_callbacks.py:

    http://www.mediafire.com/file/yeayukmidqku0j8/spotify_connect_rune_v1.rar
    @@@ Cập nhật 14/04/1018 - Mod cho volume của app Spotify đồng bộ với alsamixer tốt hơn:

    https://www.vnav.vn/threads/chia-se...fy-connect-tren-runeaudio.56409/#post-1976674

    Source tham khảo:

    http://powerpi.de/spotify-connect-a...lieren-dein-smartphone-ist-die-fernbedienung/
     
    triton and hn1804 like this.
  16. hn1804

    hn1804 Advanced Member

    Joined:
    29/2/16
    Messages:
    571
    Likes Received:
    605
    Nghe nhạc từ app spotify connect sang pi lâu bị giật tiếng là do bị gì vậy các bác . Có phải do mạng chập chờn không hay do phần cài software bị lỗi ạ .
     
  17. tml3nr

    tml3nr Advanced Member

    Joined:
    30/4/07
    Messages:
    3.082
    Likes Received:
    3.514
    Em test ở nhà 3 tuần nay rất ok ạ. Play hoàn hảo. Đường truyền của em 25mbps. Khá ổn, test lúc nào cũng max speed.

    Em vẫn nghi rune + spotify connect nó không ổn lắm với pi3.

    Hôm nào anh thử chạy moode spotify connect xem sao.
     
  18. hn1804

    hn1804 Advanced Member

    Joined:
    29/2/16
    Messages:
    571
    Likes Received:
    605
    OK. Mai anh thử moode xem sao , còn Volumio thì hoàn toàn không bị
     
    tml3nr likes this.
  19. triton

    triton Advanced Member

    Joined:
    10/9/15
    Messages:
    85
    Likes Received:
    16
    @tml3nr: Theo hướng dẫn của anh, em cài trên Pi2 - Rune và cả Dietpi chạy rất ổn định không bị mất kết nối trong khi nghe.
    Em dùng Hifiberry digi+ xuất SPDIF ra DAC ngoài nên phải mò mẫm mất mấy ngày.

    Cảm ơn anh!
     
    tml3nr likes this.
  20. tml3nr

    tml3nr Advanced Member

    Joined:
    30/4/07
    Messages:
    3.082
    Likes Received:
    3.514
    Chúc mừng anh :rolleyes:

    Em thích tiếng của Rune nên làm được cái này em sướng quá :D

    Anh chia sẻ tham số của dòng lệnh cho mọi người tham khảo ạ!
     
    Last edited: 5/5/18
  21. triton

    triton Advanced Member

    Joined:
    10/9/15
    Messages:
    85
    Likes Received:
    16
    Vâng, em sẽ viết lại cho dễ hiểu rồi đưa lên đây ạ.
     
    tml3nr likes this.
  22. triton

    triton Advanced Member

    Joined:
    10/9/15
    Messages:
    85
    Likes Received:
    16
    Em làm theo bài viết của anh tml3nr ở post: #11 trong thread này và sửa lại chút cho phù hợp với thử nghiệm trên RPi2, RuneAudio 0.4-beta_20170229, Hifiberry Digi+


    “Em mò ra được thêm một cách nữa. Install bản Spotify Connect 0.0.3. Phiên bản này mới hơn bản trước và không cần chép đè update file console_callbacks.py.


    Cách này làm hoàn toàn trên Putty. Em hy vọng là sẽ dễ hơn cho mọi người.


    Đã test trên RPi2, RuneAudio 0.4-beta_20170229, Hifiberry Digi+.


    Ta cần phải extend partition trước.


    Code:
    curl -OL https://github.com/Fornoth/spotify-connect-web/releases/download/0.0.3-alpha/spotify-connect-web.sh

    Code:
    nano /root/spotify-connect-web.sh

    Xóa tất cả 'sudo '


    Code:
    #!/bin/bash
    
    set -e
    
    
    DIR=~/spotify-connect-web-chroot
    
    
    if [ "$1" == "install" ]; then
    
      mkdir -p $DIR
    
      cd $DIR
    
      curl -L https://github.com/Fornoth/spotify-connect-web/releases/download/0.0.3-alpha/spotify-connect-web_0.0.3-alpha_chroot.tar.gz | tar xz
    
    else
    
      trap "umount $DIR/dev $DIR/proc" EXIT
    
      mount --bind /dev $DIR/dev
    
      mount -t proc proc $DIR/proc/
    
       cp /etc/resolv.conf $DIR/etc/
    
      chroot $DIR /bin/bash -c "cd /usr/src/app && python main.py $*"
    
    fi
    
    

    Code:
    chmod +x spotify-connect-web.sh

    Code:
    /root/spotify-connect-web.sh install

    Code:
    wget https://github.com/RafaPolit/moode-spotify-connect-web/raw/master/spotify_appkey.key
    
    
    mv /root/spotify_appkey.key /root/spotify-connect-web-chroot/usr/src/app

    Test thử:


    Code:
    /root/spotify-connect-web.sh --name RuneAudio --username abc --password xyz --bitrate 320

    Nếu mọi thứ OK, mình sẽ thấy RuneAudio Connect trên Spotify app và trên Putty báo lỗi như này:


    Code:
    SpInit: 0
    
    Traceback (most recent call last):
    
      File "main.py", line 27, in <module>
    
        connect_app = Connect(web_error_callback)
    
      File "/usr/src/app/connect.py", line 75, in __init__
    
        lib.SpPlaybackUpdateVolume(mixer_volume)
    
    OverflowError: can't convert negative number to unsigned

    Sửa:


    File: connect.py


    Code:
    nano /root/spotify-connect-web-chroot/usr/src/app/connect.py
    Tìm đến dòng lệnh như dưới đây và sửa lại



    Code:
    mixer_volume = int(mixer.getvolume()[0] * 655.35)
    Code:
    mixer_volume = 1 #int(mixer.getvolume()[0] * 655.35)

    File: console_callbacks.py


    Code:
    nano /root/spotify-connect-web-chroot/usr/src/app/console_callbacks.py
    Tìm đến dòng lệnh như dưới đây và sửa lại


    Code:
    playback_device_group.add_argument('--device', '-D', help='alsa output device (deprecated, use --playback_device)', default='default')
    Code:
    playback_device_group.add_argument('--device', '-D', help='alsa output device (deprecated, use --playback_device)', default='0')

    Code:
    playback_device_group.add_argument('--playback_device', '-o', help='alsa output device (get name from aplay -L)', default='default')
    Code:
    playback_device_group.add_argument('--playback_device', '-o', help='alsa output device (get name from aplay -L)', default='snd_rpi_hifiberry_digi')

    Code:
    if self._args.playback_device != 'default': 
    Code:
    if self._args.playback_device != 'snd_rpi_hifiberry_digi': 

    Code:
    corected_playback_volume = int(min_volume_range + ((volume / 655.35) * (100 - min_volume_range) / 100)) 
    Code:
     corected_playback_volume = 1 #int(min_volume_range + ((volume / 655.35) * (100 - min_volume_range) / 100)) 

    Tạo file service:

    Code:
    nano /usr/lib/systemd/system/spotify-connect.service

    Code:
    [Unit]
    
    Description=Spotify Connect
    
    After=network.target
    
    
    [Service]
    
    ExecStart=/usr/bin/sh /root/spotify-connect-web.sh --name RuneAudio --username abc --password xyz --bitrate 320
    
    Restart=always
    
    RestartSec=10
    
    StartLimitInterval=30
    
    StartLimitBurst=20
    
    
    [Install]
    
    WantedBy=multi-user.target

    To test the service execute:


    Code:
    systemctl start spotify-connect

    Nếu OK, ta enable service (start on boot):


    Code:
    systemctl enable spotify-connect


    Sau khi install v0.0.3. Mình có thể update lên v0.0.4 bằng cách tương tự như trên. Nếu mình install v0.0.4 trước, nó sẽ không chạy.


    Ghi chú: username và password là của account thật nhé!


    More information:


    https://github.com/Fornoth/spotify-connect-web/releases


    Many thanks to @Fornoth, @hongdagx35, @Lazerharp, @Stert...”


    Em có tham khảo thêm tại đây:

    https://volumio.org/forum/spotify-connect-t2811-90.html

    Thanks to @domars


    Cảm ơn anh tml3nr đã chia sẻ !

    triton
     
    tml3nr likes this.
  23. tml3nr

    tml3nr Advanced Member

    Joined:
    30/4/07
    Messages:
    3.082
    Likes Received:
    3.514
    Cảm ơn anh @triton đã update cách làm cho Hifibery Digi+. Em sẽ lưu lại cho các anh nào có nhu cầu :rolleyes:
     
    Last edited: 7/5/18
    triton likes this.
  24. tml3nr

    tml3nr Advanced Member

    Joined:
    30/4/07
    Messages:
    3.082
    Likes Received:
    3.514
    Spotify Connect cho Volumio 2.389:

    Em mò tiếp cách setup theo kiểu powerpi.de (Fornoth) vào Volumio. Cách này có cái hay là khi mình chỉnh volume trong Spotify nó kéo theo được volume của Pi. Rất tiện khi dùng DAC có hardware volume.

    Đầu tiên ta phải enable root login:

    - Vào http://volumio.local/dev bật SSH.

    Code:
    sudo nano /etc/ssh/sshd_config
    Edit:

    Code:
    PermitRootLogin no
    Thành ra:

    Code:
    PermitRootLogin yes
    Dùng putty login bằng user root / password volumio:

    Code:
    curl -O curl -OL https://github.com/Fornoth/spotify-connect-web/releases/download/0.0.4-alpha/spotify-connect-web.sh
    
    chmod u+x spotify-connect-web.sh
    
    ./spotify-connect-web.sh install
    Copy file spotify_appkey.key vào /root/spotify-connect-web-chroot/usr/src/app

    Test:

    Code:
    ./spotify-connect-web.sh --playback_device sysdefault:CARD=BossDAC --mixer_device_index 1 --mixer Digital --username abc --password xyz --name Volumio --bitrate 320
    Nếu OK. Ta tạo file service:

    Code:
    nano /lib/systemd/system/spotify-connect.service
    Code:
    [Unit]
    Description=Spotify Connect
    After=network.target
    [Service]
    ExecStart=/root/spotify-connect-web.sh --playback_device sysdefault:CARD=BossDAC --mixer_device_index 1 --mixer Digital --username abc --password xyz --name Volumio --bitrate 320
    Restart=always
    RestartSec=10
    StartLimitInterval=30
    StartLimitBurst=20
    [Install]
    WantedBy=multi-user.target
    Test spotify-connect.service:

    Code:
    systemctl start spotify-connect
    Set cho spotify-connect.service chạy khi boot:

    Code:
    systemctl enable spotify-connect
    Vậy là xong ạ!

    @@@ Tùy chọn: Fix cho volume của Spotify app đồng bộ hợp lý hơn với volume Digital của Pi:

    Code:
    nano /root/spotify-connect-web-chroot/usr/src/app/console_callbacks.py
    Thay đoạn này vào chổ tương ứng trong file console_callbacks.py. Từ @userdata_wrapper đến cuối file:

    Code:
    @userdata_wrapper
    def playback_volume(self, volume):
      print "playback_volume: {}".format(volume)
      mixer.setvolume(int(50 + (volume / 655.35) / 2 ))
    
    connection_callbacks = ffi.new('SpConnectionCallbacks *', [
      connection_notify,
      connection_new_credentials
    ])
    
    debug_callbacks = ffi.new('SpDebugCallbacks *', [
      debug_message
    ])
    
    playback_callbacks = ffi.new('SpPlaybackCallbacks *', [
      playback_notify,
      playback_data,
      playback_seek,
      playback_volume
    ])
    [​IMG]
     
    Last edited: 30/5/18
    triton likes this.
  25. tml3nr

    tml3nr Advanced Member

    Joined:
    30/4/07
    Messages:
    3.082
    Likes Received:
    3.514
    Em tóm tắt lại tình hình setup Spotify Connect hiện tại cho mọi người dễ theo dõi.

    Có lẽ Spotify có thay đổi API. Nên moode / SC raspotify và Volumio / Spotify Connect2 cần phải cập nhật bản mới nhất mới chạy được theo cách không cần nhập user / password.

    # RuneAudio:

    - Vẫn như cách cũ ở trang 1 (powerpi.de). Cần phải nhập user / pass.

    # moode audio:

    Cách 1:

    (raspotify). Không cần user / pass. Cài bản mới nhất trên web theo cách ở trang 1.

    More info:

    https://dtcooper.github.io/raspotify/

    Cách 2:

    (powerpi.de). Cần phải nhập user / pass. Cách này khi chỉnh volume trong Spotify nó kéo theo được volume alsa của moode. Rất tiện cho những ai dùng DAC có hardware volume. Cài theo cách ở trang 2.

    # Volumio:

    Cách 1:

    Vẫn dùng plugin của balbuze giống như bản theo Volumio stock. Cần phải update. Cách này không cần user / pass. Các bước như sau:

    - Disable và remove plugin Volumio Spotify Connect2 trong Volumio

    - Vào http://volumio.local/dev bật SSH.

    - Dùng putty kết nối vào:

    Code:
    wget https://github.com/balbuze/volumio-plugins/raw/master/plugins/music_service/volspotconnect2/volspotconnect2.zip
    
    mkdir ./volspotconnect2
    
    miniunzip volspotconnect2.zip -d ./volspotconnect2
    
    cd ./volspotconnect2
    
    volumio plugin install
    Sau đó vào giao diện web của Volumio. Trong mục Installed Plugins bật Volumio Spotify Connect2 lên. Bấm vào setting, set volume 100% rồi bấm save.

    More info:

    https://github.com/balbuze/volumio-plugins/tree/master/plugins/music_service/volspotconnect2

    volumio_sc2.jpg

    Cách 2:

    Theo bài viết bên trên ở trang 2. Cần phải nhập user / pass.
     
    Last edited: 30/5/18
Tags:

Share This Page

Loading...