Remix.run Logo
▲ How Not to Build a Music Player(alichraghi.github.io)
62 points by vinhnx 6 hours ago | 25 comments
▲winternett 4 hours ago | parent | next [-]

It's been under my skin for a long time now, but every single free music player app I've used in the past 8 years plays my locally stored mp3s in the exact same order each time the shuffle button is on. Many others complain about that too.

I don't know if it's happening on Android OS level, but even VLC, plays songs in the exact same predictable order. I've left support notes on VLC's forums, and submitted the issue to issue cues and there are no responses each time.

None of that encourages me to pay for a premium app, shuffle has been around since CD changers.

▲Hobadee 4 hours ago | parent | next [-]

I would rather have the same "random" order than what Spotify does; random never plays some songs, and overplays other. I get true random has the possibility of that, but when I've heard the same song for the 4th time in an hour, on a 20-hour playlist, something is wrong.

▲cooljoseph 2 hours ago | parent [-]

It sounds like maybe what you want is to have the "shuffle" mode play songs close to truly randomly while still penalizing songs that have been played too much recently. This gives us an optimization problem:

    minimize KL(π || uniform) - β E_π[times played already],
where β is an inverse temperature determining how much you dislike repetition and π is your policy. Here I've arbitrarily chosen a reverse KL divergence because it leads to a nicer closed form:

    π(song) ∝ exp(-β⋅"times song played already").
I wonder if anyone has implemented this before in a music playlist.
▲egypturnash 5 minutes ago | parent [-]

Easy version: Make a smart playlist whose criteria are 'last played is not in the last 3 weeks, last skipped is not in the last 3 weeks'. Randomize within that. Possibly add some other conditions like 'genre is not podcast'. I've been having iTunes/Music.app do this for... probably at least a decade, at this point, it doesn't track when you made playlists so this is just guessing.

▲eddythompson80 3 hours ago | parent | prev | next [-]

I have this issue with youtube music only for some reason. For me "Shuffle" seems to be starting random, then after a handful of songs entering a loop of 6 or 7 songs. I never figured out why or looked it up, I just refresh the page. I know it must be only me somehow, but don't know what's happening.

▲entropie 3 hours ago | parent [-]

I think you can have a rss feed of your playlist, you could grep the urls, | rand them like you want and play with mpv or just download everything with yt-dlp.

▲CWuestefeld 3 hours ago | parent | prev | next [-]

My car's player (reading from a flash drive full of MP3s) doesn't have "shuffle", it has "random". The difference is subtle, but it means that each time it advances to a new track, it selects that at random. The result is that I never hear all the tracks in an album/playlist without hearing a bunch of repeats. Infuriating!

But when I play from my phone or PC, I use PlexAmp (backed by my Plex media server), which is the opposite extreme. Not only does it know what randomly shuffling is, but the server has analyzed the sonic profile of every track, and knows about similar artists and similar albums. So you can play an "artist radio" featuring that artist and other related stuff. And you can choose an auto DJ, which inserts between tracks the closest sonic match to the song it just played, or a brief detour of about 3 tracks that are spaced along the path from the track that just played to the one that's about to play. It's fantastic for discovering stuff you haven't heard in a long time within a very large library.

▲WalterBright 3 hours ago | parent | prev | next [-]

Pretty much every USB music player has the same faults:

1. shuffle play does not work

2. crashes if there are more than N songs

3. does not find songs in subdirectories

All of these are trivial to fix. I do not understand the programmers who make the firmware.

▲0gs 3 hours ago | parent [-]

wow hacker news wins again. i am going to fix these in my music player. i think 2 & 3 are chill already... and i can totally fix 1. thanks!

▲WalterBright an hour ago | parent [-]

To implement shuffle play, it is not necessary to actually shuffle filenames in memory. Just generate a random number modulo the number of files, and then play that file. That way your program can shuffle play any number of files, no worries about running out of memory.

By the way, the Roku box has a "media player" app in it by default, and it cannot shuffle play more than a handful of files. Completely useless.

▲WalterBright an hour ago | parent | next [-]

BTW, Windows Media Player is the winner, as it "just works". Just point it at the root directory of the music files, turn on shuffle play, and it works, and doesn't crash.

▲moron4hire 37 minutes ago | parent | prev [-]

That's random play, not shuffle play. Random play can repeat songs before all songs are played. Shuffle play will play all songs exactly once before any repeats occur. Random play "puts the card back into the deck" before dealing the next one.

▲jancsika 3 hours ago | parent | prev | next [-]

Amperfy for the Iphone randomizes the shuffle.

I just looked at the code and it's apparently using the Fisher-Yates shuffle with a call to arc4random each pass. It's literally eight lines of Swift!

I've never suggested this before, but if the Android app store has truly been as bad as you claim for as long as you claim, you should seriously consider buying an Iphone to solve your problem.

▲Gualdrapo 4 hours ago | parent | prev [-]

Is what you call the "shuffle button" a "shuffle playlist" button or a "shuffle mode" button? There is a subtle difference between those two and for what I understand you want the second

▲bombcar 4 hours ago | parent [-]

Most people want the second - if they hit it, it picks a random song, and then plays all of the remaining songs randomly before repeating.

Few people want to shuffle the playlist (which is closer to above) or worse, to actually randomly select a song each time.

▲mojuba 35 minutes ago | parent | prev | next [-]

> I was surprised by my own ignorance and how much LLMs like to complicate stuff.

Exactly and it's like a plague. I think the main reason is that LLMs are generators, they like to generate code where code removal or reduction would solve the problem just as well. You ask them to fix something, they generate a fix. You tell them the fix didn't work, now they generate a fix for a fix, whereas a fix that would also reduce complexity existed from the start.

With a fair amount of babysitting and constantly reminding the agent that code removal is an option, you can eventually get a decent codebase but I wonder why this isn't a default. Because they are trained on mediocre code that is the vast majority of what's available on the internet? Most likely.

▲sho a minute ago | parent [-]

> the main reason is that LLMs are generators, they like to generate code where code removal or reduction would solve the problem

Don't over-index on this choice of words. LLMs can just as easily generate a diff that removes or refactors code, they don't have any intrinsic "preference" to always add more code, unless it's been trained into them.

A lot of the early training had concentrated on "wow factor" one-shot style demoable use cases, where the models indeed ended up with a tendency to assume they were in a "produce something new for me right now" situation and often or always started churning out additional code, even without all relevant information. As training regimes improve, and as customer demand evolves, this is changing, and the latest big models place a lot more emphasis on maintenance tasks - still not enough, but it's at least in the mix. As they mature, I'd expect the models' "instinct" to gradually align with what everyone's idea of a senior software engineer is, taking time to figure out if they can simplify and refactor rather than always adding more.

It's a new field, it will take time to get it right, but I don't doubt it will eventually be right.

> Because they are trained on mediocre code that is the vast majority of what's available on the internet

Again, this is outdated. It's true that the earliest training took this "spray and pray" approach, but data quality filtering is now a huge focus and the labs have made a lot of effort (and progress) in figuring out what good code is and getting the models to follow that. They've massively improved, in my experience, and it'll only get better. Again - give it time, this is new.

▲Hobadee 4 hours ago | parent | prev | next [-]

"AMP" is unfortunately close to "AIMP", another music player. (https://aimp.ru/)

▲sowbug an hour ago | parent [-]

And Winamp.

▲hoooooooooome 2 hours ago | parent | prev | next [-]

Musicolet for android has a shuffle, and also folder view, that works very well. Truly shuffled up.

▲ta2112 4 hours ago | parent | prev | next [-]

> I’ve got no pre-rewrite history of the repo to check).

I love this type of story, because it describes a different Internet that I'm familiar with. And honestly it sounds pretty rough out there! But regardless, we all should be using some kind of version control (git), and as an added bonus you'd get your pre-rewrite history from it.

▲eddythompson80 3 hours ago | parent [-]

I mean they mentioned they had the code on codeberg initially, so it must have been in a git repo before. Maybe they just did the ol' `rm -rf .git && git init .`

▲sandreas 2 hours ago | parent | prev | next [-]

Interesting Story. Starting my own hardware music player as a learning project[1] (that will probably take years until the first release) I noticed how MANY music player projects are out there (software and hardware ones).

This seems to be a field with so many different approaches and requirements, that no solution can fit them all and everyone settles with the least annoying one or starts their own.

Personally, I've found that since breaking up with macOS/iOS in 2020 my most missing feature is using my headphone remote to control volume or skip songs without taking my phone out of my pocket / touching my keyboard. It's still in my muscle memory, because I'm using my iPod Nano 7 to listen to audio books a lot and while every iPod and MacBook does support this, Linux capable notebooks don't.

Besides this single feature, for music I found navidrome with smart playlists[2] and Substreamer[3] / DSub[4] to be a great way to listen to local music, since Substreamer supports OFFLINE sync for playlists. So every time I get home I sync my smart playlists, which includes a "last played" filter / ordering - so I get to listen to "new" music every time.

Unfortunately the headphone remote stuff probably will never be fully fixed on Android, because google chose to block "longpress" on OS level for their own Voiceover, but like I said: The least annoying option.

For audio books I can recommend Audiobookshelf[5], which is self hosted and can be combined with the official Android app or some third party ones (Lissen, Storii and Voice from Paul Woitaschek). I'm probably sticking to my iPod until it dies completely - but lately I found the HiBy R1 to be Linux based and hackable[6], maybe I try to implement my own player / UI for it :-)

1: https://github.com/nanowave-player/nanowave-ui

2: https://www.navidrome.org/docs/usage/features/smart-playlist...

3: https://substreamer.org/

4: https://f-droid.org/de/packages/github.daneren2005.dsub/

5: https://github.com/advplyr/audiobookshelf

6: https://github.com/Jepl4r/sonix-player

▲dead_hn_theory 4 hours ago | parent | prev [-]

This post makes no sense. The author goes from having no internet due to a bombardment to LLM'ing. I find it hard to share the plight of a warzone when they go unhinged to build their own audio player afterwards (?!). If I want a music player every OS comes with one, and phones hold enough storage. USB thumb drives are also good. Failing that, burning CDs and using rechargeable batteries is another off-the-grid solution that will work fine, and CDs are easily transportable and will last for decades. Slightly physically damaged CDs are somewhat resilient and can be brought back to life with toothpaste, so they're somewhat "better" than files which shit the bed if there is any data corruption.

▲summermusic 3 hours ago | parent [-]

The point is that the author wrote the music player app because they wanted specific features and for their own pleasure/coping.