💾 Archived View for hexdsl.co.uk › log › 20210406-I_setup_MPD_Streaming.gmi captured on 2022-01-08 at 13:44:13. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2021-11-30)
-=-=-=-=-=-=-
DATE: Tue 06 Apr 2021 By: HexDSL@Posteo.net
I have used Spotify for years now but about six months ago I stopped using it on my desktop computer. Spotify is fine but I wanted to use something more "Linux" on my main machine. Having an insanely ornate application like Spotify open next to three terminals just seemed strange, from an aesthetic point of view.
On my PC I switched to using MPD (Music Player Daemon) and NCMPCPP (worst name ever for an application). This solution has worked well for me for a while now but its been bugging me that I still fall back to Spotify on my phone. I do have a Plex (home) server but its never been something I enjoyed using for music.
With this in mind, a few days ago I began half arsedly search for a solution that fits with my sensibilities as a nerd. *My spell checker assures me that "arsedly" is not a work. I'm leaving it there as an act of defiance*
The solution, as it turns out was MPD and this android application called MALP. A little help from the Arch wiki and some nice folks in my Discord and I had the theory down.
I installed and setup MPD on my home server. Set a "httpd" as the only output and used my routers port forwarding to get the outside internet to route correctly in the inside of the network.
The then setup the MALP application on my phone. Started the Audio stream and BOOM. Works.
Once I was happy with the setup I used systemd to start MPD and I'm all done.
On my PC I have a few scripts to load an NCMPCPP instance connected to the server and another quick alias to connect to the stream via mplayer.
I'm still using a locally served MPD on my main machine right now, but may switch right over in a few days when I'm done tinkering. Or I'll leave it as it is because, functionally speaking there is no difference.
I made a few mistakes going into this configuration by thinking of things all wrong like. Yeah.
I assumed that I would load NCMPCPP on my main PC, connect to the server and the sound would magically "happen" the reality is that the MPD control and the audio stream are not related. I have to connect to an audio stream separately do NCMPCPP. That wasn't actually very clear with the documentation, or I was misunderstanding EVERYTHING. Stands a change if I'm honest.
In my case this is an old pentium anniversary CPU in an old case with 8GB of RAM and more hard drives than fit in there. I call it 'Augur' and It literally shares files over SSHFS, hosts Plex and how hosts my MPD stream. Its not a monster. With the things its running I use about %10 of its resources on a busy day. Short story - this will work on a toaster, in case you were wondering.
My MPD config contains all the usual things AND this:
bind_to_address "192.168.1.101" bind_to_address "localhost"
Those two lines above were important to get it to work over the internet. Binding to the local IP seems to help with the overall routing.
port "6600"
Can be literally anything that forwarded to your server via the router interface on your, err, router I guess. Mines a TP link and its not as shit as every other router I have ever had. Remember this is the port of the MPD server for picking music and shit, not the port of the audio stream.
audio_output { type "httpd" name "Augur" encoder "lame" port "9001" bitrate "128" format "44100:16:1" always_on "yes" mixer_type "software" }
That, and the usual configuration settings (read "defaults") will start the stream and make it accessible via the internet.
That instance of PORT there that's the port of the AUDIO stream, that is different to the port of the MPD client above. These MUST be different or it will launch MPD but not fire up the stream - Yes, I did this. Yes, I *am* a silly goose.
You **might want to** (100% should) also look at the PASSWORD settings to stop someone monkeying with your stream if its got internet access.
On the client machine I already have a working MPD so I would only want to connect to the server instance when I want to manage my stream settings/queue. So I made an alias for this command...
ncmpcpp 192.168.1.101
That will simply start NCMPCPP but connect to the remote server not the local one. Nothing more too that really. I literally guessed that and it worked.
Now you can login and manage he stream you need a way to make the noise happen. You can literally just visit the URL of the server in a browser if you want the most basic connection to the stream. in my case that would have been:
http://192.168.1.101:9001
You can also use your internet address. In my case I have access to a static IP. You may want to do this form a VPS if you don't have a static IP. Because it may change whenever you reboot your network thingies.
The better and less shit way to do it is with an application, MPV works fine but it draws a window by default and you have this black box to deal with. BUT, mplayer is better at this so you can launch it with
mplayer http://192.168.1.101:9001 &
That will basically beep playing the stream until you kill the process.
For bonus points you can get yourself a cosmetic URL for that and then feed that to mplayer.
mplayer http://fucking_good_tunes_innit.yes:9001
That's not a real URL, or at least I don't think it is.
you can connect to the stream with pretty much anything that can play audio over the internet. For my phone I did a DuckDuckGo and found MALP you login and have a separate section for MPD and stream. you setup your music and then click "start stream" its not very intuitive but it works wonderfully.
Why all the arch wiki posts I hear you ask? Because they are well written and, you know... I use Arch. Gentoo wiki is also great fwiw.
As I said, at the moment I'm on the fence as to if I just use it for all my music. I think I'm going to. Then I'll have the same play lists everywhere. That will be nice. I think.
Also, Need to look at Jellyfin again, so maybe I can properly self host my own netflix. Plex is fine but I'm still relient on a third party and that worries me on some level.
Please remember, streaming music over the internet may not be entirely legal. I literally have no idea, but as far as I'm able to tell, I am the only human that knows the real IP and PORT so I guess I'm fine.
Please email any comments to hexdsl@posteo.net