I wrote a music player (2022)

https://lobste.rs/rss Hits: 1
Summary

2024/02/29 edit: fixed a few typos and links, improved the markup.This is a partial and inaccurate translation of a post with the same title I published the other day on my Italian capsule.Moved by curiosity I wrote a small music player. The ideas was to see if it was possible to decode the audio files in a tightly sandboxed process.TL;DR: it was an error. I ended up writing a thing I like, now I have to maintain it!amusedIt’s a small program that plays music on the background and is commanded by a really simple command line interface:$ amused add *.mp3 # enqueue all mp3s $ amused play playing /path/to/music.mp3 $ amused pause $ amused status paused /path/to/music.mp3 End. Well, there is a little bit more to be honest. It has a unique (in its category I mean) behaviour with regards to pipes, but I’d like to describe my thought process before showing how it plays with the shell.The initial idea was to have a daemon process (“amused”) that plays the music and a client (“playlistctl”?) to control it. Akin to mpd/mpc if you want to. I pretty quickly discarded the idea and went with a single executable – amused – that is both a daemon and a client, and that automatically spawns the daemon if needed. It’s more easier to use I guess.One of the first command to be implemented was ‘show’ to print all the enqueued files. Amused is a simple program which has only the notion of the current playing queue, and I wanted to keep it as simple as possible. In particular I didn’t want to add some kind of state persistence. All the state is manipulated via the command line and is ephemeral: once you kill it, it’s gone.Then I thought that I could use the ‘show’ command to dump the state to the disk, so I wrote a ‘load’ command to re-import it from a file:$ amused show > amused.dump $ # then, later... $ amused load < amused.dump Pretty cool if I can say so. At this point I had a program lying around that I started to really like, so I was thinking of adding just some more features so tha...

First seen: 2026-07-27 14:29

Last seen: 2026-07-27 14:29