On both iOS and Android, HTML can play videos and mp3s while the screen is turned off. So maybe it is possible?
I just never polished it to publish it, but it is quite easy and I guess ChatGPT can help with the basics as no arcane knowledge is required. (Except maybe the playing while screen is off.)
You also need a small node script, though or something different with system access to scan the media files. I think in browser tools make this now somewhat possible without(beware of security restrictions), but my approach is simply a node script scanning the music folder and generating a list that the media player consumes to find files for the player. I still didn't got around to make it automatic, but I don't add so much music (anymore).
I guess I will give it a try to see, how good it works a mobile player nowdays. I always wanted to upgrade it, so I can connect to spotify from my player as I hate the spotify mobile app.
https://stackoverflow.com/questions/64283711
It works nicely in Chrome on the desktop and on Android. Not sure how the situation is on iOS.
When I made https://ambiph.one I ended up having to route everything through a MediaStreamAudioDestinationNode to trick Safari into thinking it's a livestream, which is apparently the only type of audio allowed to play in the background
Minimal demo here if it's helpful for anyone: https://codepen.io/matteason/pen/VYwdzVV
Edit: https://caniuse.com/native-filesystem-api
Edit2: Just a few posts down: https://webamp.org/
If you are playing music through Spotify in the background, foreground audio in Snapchat still plays normally while recording and playing back just recorded snaps, as well as snaps or memories you have prepared earlier. Sometimes you need to start playback on Spotify again via Control Center, because Snapchat steals focus or takes priority for audio output or something, but it is just part of the jankyness of this workflow, which is probably not intentionally designed to be used the way I use it. If you combine these quirks with Screen Recording, you can make simple audio loops by recording simultaneously via Snapchat and iOS Screen Recording, then use those videos as uploads to Snapchat to stack the loops over each over by selectively queuing them, with audio from a video in Snapchat playing at the same time as audio from Spotify.
It’s kind of a weird workflow, but it’s neat that it works. It feels intentional, as most apps stop background audio playback when starting recording on the same device, but at least Snapchat does not do this, so it’s at least technically possible.