Node-RED Music Player Client

Requirements

  • Raspberry Pi (1/2/3)
  • Docker Images
    • easypi/node-red-arm
    • easypi/mpd-arm
  • Internet Access

Node-RED Flow

Central Node Config

[
  {
    "id": "ef1263b5.ce2c",
    "type": "exec",
    "z": "a01b1406.cbbbf8",
    "command": "mpc -h mpd",
    "addpay": true,
    "append": "",
    "useSpawn": "",
    "timer": "",
    "name": "mpc",
    "x": 486.5,
    "y": 281.5,
    "wires": [
      [
        "6ba27546.01e5bc",
        "25a75634.86a05a"
      ],
      [
        "6ba27546.01e5bc"
      ],
      [
        "6ba27546.01e5bc"
      ]
    ]
  }
]

Docker Deployment

# docker-compose.yml

node-red:  
  image: easypi/node-red-arm
  ports:
    - "1880:1880"
  links:
    - mpd
  volumes:
    - ./data:/root/.node-red
  privileged: yes
  restart: always

mpd:  
  image: easypi/mpd-arm
  ports:
    - "6600:6600"
    - "8800:8800"
  volumes:
    - ./mpd.conf:/etc/mpd.conf
    - ./music:/var/lib/mpd/music
    - ./playlists:/var/lib/mpd/playlists
  devices:
    - /dev/snd
  restart: always
# mpd.conf

music_directory    "/var/lib/mpd/music"  
playlist_directory "/var/lib/mpd/playlists"  
db_file            "/var/lib/mpd/database"  
log_file           "/var/log/mpd/mpd.log"  
pid_file           "/var/run/mpd/mpd.pid"  
state_file         "/var/lib/mpd/state"  
sticker_file       "/var/lib/mpd/sticker.sql"

input {  
        plugin "curl"
}

audio_output {  
        type            "alsa"
        name            "Default Audio Device"
        mixer_type      "software"
}

audio_output {  
        type            "httpd"
        name            "My HTTP Stream"
        encoder         "vorbis"
        port            "8800"
        bitrate         "128"
        format          "44100:16:1"
        always_on       "yes"
        tags            "yes"
}
$ mkdir -p ~/fig/mpc/playlists
$ cd ~/fig/mpc/

$ vim -p docker-compose.yml mpd.conf

$ wget -O- https://github.com/EasyData/shoutcast/releases/download/latest/shoutcast_2016-08-20.m3u.gz | gunzip > playlists/shoutcast.m3u

$ docker-compose up -d
$ docker-compose exec node-red bash
>>> apk add -U mpc
>>> exit

$ firefox http://raspberry-pi-ip-address:1880/