Playing MP3s on an iPhone, an Impossible Challenge
I just want to play my MP3 files on my phone.
I just wanted to play, on my iPhone, MP3s I already have while doing dishes. I am not asking for a million dollars. Hell, most of the work is already programmed into the web browser, yet Apple still goes out of its way to be dick and constantly prove that their products exist only as collateral in an environment they fully control.
My favorite digital audio players feature a list of music to choose from, a big damn list of everything I have ever imaged. My long time favorite is WinAmp, because it is modular and primarily just an audio player with a big damn list of everything. Its stupid simple for stupid old people from the 90s: a player and a list. Bloody fantastic!
The first thing any sane person does is look for something like that from the App Store so that they can just play music without having to reinvent nuclear weapons. It doesn't exist. All the applications on the App Store that look like they should be able to do this don't.
Apple is an asshole.
If you are going to make this work on the iPhone you have only two options: something that works in the web browser or an App Store application that makes use of Apple's iOS APIs. Both of those options will make use of the same exact API to dynamically create a list of things from files, a file system method that provides a list of files from a directory, or directory tree. That sounds simple enough because the web browser provides a window.showDirectoryPicker() method, right? No, Apple restricts access to that method in iOS. It is there in Safari, their web browser, and then restricted on iOS after the fact because Apple is full of assholes. This does not just effect browser applications, but it also cripples applications from their App Store, which is why you cannot find this on the App Store.
So, a dynamic playlist is not an option on the iPhone. Why would they do extra work to be assholes you ask? Because they don't want you to use applications to access media directly.
- They want you to be fully dependent upon streaming services that retain access to the media, so that you pull the media across the internet on each and every play.
- They want you to be fully dependent upon a suggestion algorithm to determine what plays next.
Originally the motivation was to force people to use their iTunes store to access all media, because that one restriction single-handedly turned Apple into the most valuable company in history, at least for a time. As other streaming options emerged, such as Amazon Music, the motivation softened to just device addiction. Even if cheaper alternatives emerged to the iTunes insanity Apple could still, at least, keep people reliant on their greater App Store its restrictions.
Walk past the stupid.
So, dynamic playlist creation is not possible on an iPhone because Apple is a dick, a fat giant dong. The word dong recently came up in a game of Scrabble where the definition clearly means a sound emanating from a large bell, but I am using that word as slang to mean a painfully swollen penis.
Instead we will bypass dynamic playlist creation by instead creating a static list of music using applications outside the Apple ecosystem. In my case I wrote a TypeScript application for Node.js that writes a single web page. This web page contains an audio player using the Web Audio API and a big list of files to play. This worked great for a few months... until the next iOS update forced on my phone and then it just stopped working.
Previously I described Apple as a horribly scary penis, as in a weapon of mass destruction coming to cause you deliberate harm. Now its more like a venereal disease in that after it tears you apart it leaves you with a lasting gift to affectionately remember it on each and every use. In this case Apple, deliberately, further crippled their Safari browser on iOS by eliminating the parsing of JSON data objects after a certain size.
Solving for stupid.
We can solve for this too. Let's not forget we have an application already written that executes far outside the control of Apple and just loads in a web browser. We just have to ensure our data is parsed in a series of small fragments instead of a single large piece of data.
To solve for this the music application write the data into a series of data files completely external to the one web page with the player and list. Each of these data fragments will be composed of data representing no more than 500 song files. The one web page containing both the player and list will then request these data files one at a time in order, and from that data it will dynamically build its song list into the web page. This works great.
Maximizing availability.
The Apple stupidity is solved, but there is still one problem left to solve for. I want my one giant playlist to be available to play from anywhere on the internet, but I do not want it to be available to the public. I want to play my music, but I don't want to became the personal music equivalent of a small time drug dealer who later gets sued to death for copyright violations.
The solution for this is two fold:
- Keep all the music files on a private network. This could be a non-routable IPv4 network or an IPv6 subnet with strong access controls. IPv6 is challenging because support remains absent in under developed areas of the world and I find support for IPv6 is unpredictable on Windows.
- Run a self-hosted VPN solution to tunnel into your private network.
The de facto solution for self-hosted VPN is WireGuard. WireGuard is absolutely amazing, but it can be challenging for the less gifted (includes me) to get working across a variety of devices for a IPv6 solution. Instead I chose to go all out on vendor lock-in with a commercial solution from TailScale. TailScale is a WireGuard solution paired with static public IPv4 addresses, which is both secure and maximally convenient. I have my house fully wired up on their free tier and so far have never encountered bandwidth limitations.
TLDR;
- My single page audio application with a giant playlist that works amazingly on iPhones - https://github.com/prettydiff/mp3-master-list/
- My commercial solution to privately expose my music across the internet - TailScale