Use mpd to make a radio that you can listen to and control from any computer. This guide presumes a local network setup, but nothing is stopping you from doing this over the internet.
xx.xx.xx.xx is the local network ip, xx.xx.xx.yy is the ip of the
machine running mpd
A single machine that contains media files and runs mpd. Thousands of other machines that can reach the mpd machine and can play audio streams. ncmpc.
The only difference from the local configuration is the output block. The user running mpd needs access to these files. Adapt the paths appropriately.
music_directory "~/music"
playlist_directory "~/.config/mpd/playlists"
db_file "~/.config/mpd/mpd.db"
log_file "~/.config/mpd/mpd.log"
pid_file "~/.config/mpd/mpd.pid"
state_file "~/.config/mpd/mpdstate"
sticker_file "~/.config/mpd/sticker.sql"
audio_output {
type "httpd"
name "fishradio"
port "7331"
encoder "lame"
bitrate "192"
format "44100:16:2"
mixer_type "software"
always_on "yes" # if a playlist ends, this doesnt kill the stream
}
This will start an http server that will stream music that is queued in mpd. There is a billion other options you can define for the audio output, in my case this seems to be the bare minimum for my own needs.
The port "7331" in this example is for the audio stream. The default port 6600 (doesn't have to be defined) will be used for manipulating playlists.
If relevant, allow access to the two ports in /etc/pf.conf.
In this example xx.xx.xx.xx is the local network, meaning the radio will
only be accessible by local machines.
...
mpd = "{ 6600 7331 }"
...
pass in inet proto tcp from xx.xx.xx.xx/24 to port $mpd
...
Finally, run mpd. Note that initially the http server will not run until music is playing. Use mpc/ncmpc to select
some files and play them. You can test that it plays by opening http://127.0.0.1:7331 in a media player or a web browser.
Now you need the ip address of the mpd machine, ncmpc and mpv.
Use ncmpc to select music, make a playlist, etc. Use a media player (mpv) to connect to the stream.
$ ncmpc --host=xx.xx.xx.yy --port=6600 $ mpv http://xx.xx.xx.yy:7331
Cool.