I love Spotify and I have the App for some years now. I use it a lot when I drive because I can't bear Radio, ads and other silly stuff distracting me from just enjoying the road. It's the closest thing to AdBlock for in car entertainment to me.

There are two caveats though or rather downsides to the way I use Spotify. I can't add my own audio like for example german_jokes_podcast39.mp3 or 1_hour_of_villager_sounds.mp3 and the places I drive to have sometimes no Internet coverage (roundabout 10km away from Ingolstadt) which means I need to have set the songs or playlists to "Download" before I hit the road. Which introduces friction. I know, it's just a button, but after this venture I'm not taking any button for granted anymore.

Obviously, I can sit down every now and then and start iTunes, connect my phone with cable or wifi then contemplate about what new forced update I need to install or what I need to pay for next and then pray for the Music app to not delete my files at some points and what not. This means a lot of manual labor for ultimately a solved Problem (think rsync).

Freedom aka my hardware, my rules?

I have no issues with iPhones or something but I adhere to the German concept of Freiheitstrieb which states that it is a basic human instinct to want to escape from captivity. And the whole ecosystem surrounding iPhones is a bit of a lock-in as you will see later.

So why you don't buy an Android?  - That is a fantastic question! I have some Android phones I use them to make memes and have no place for audio files (and the fact that I can't manage multiple Sim cards let alone multiple phones). So, priorities.

My first thought was: Hmm, I want to synchronize my own audio files and funny jokes I tell myself  to my device without having to think about it very much. The first usual suspects are iCloud, Dropbox, Box or any other cloud solution that works on iOS. But I have second thoughts about those services since I ultimately give them my jokes and some of the sounds or audio I want to play are very personal and can also get deleted or worse.

Cloud Synchronization

Enter Nextcloud. This is a fantastic solution! I installed it on my personal servers which I pay 2€ per month for (shoutout to Scaleway) setup some ssl and installed the Nextcloud iOS app and loaded some audio files. The cool thing you can do with the app is to mark a folder for "Offline Viewing" similar to the Spotify functionality. The files were synced and downloaded to my phone (the setup and configuration was smoooth sailing so far) and chose the first track. It plays, BUT:

  • There was no way to skip to the next audio track
  • Once it is done playing, that's it, you're done!
  • You can't open the files in another player app (eg: VLC) without having to duplicate them manually to the other app

So in case I'm bored with my ramblings I will need to sit it through without being able to control the playback. And everyone knows that you should not use your phone while driving so that was a no go selecting the tracks on the fly - drive.

Luckily, the Nextcloud iOS App is open source and hosted on Github. So I headed there looking for solutions and all I could find is an issue from pre-Corona times: Playing multiple mp3s (yes I wrote some comments too). It seems I'm not the first one to have this brain fart and some people came up with workarounds as well, like use CloudBeats or other solutions to synchronize your WebDav (what Nextcloud exposes) to your device.

Available Options for Webdav with iOS

Cloudbeats costs around 7,99€. Nothing wrong with the app, seems to work and even has positive reviews in german.

Another option would be Evermusic, like recommended on reddit, but on the review page there is a very interesting review by "Nasty McNizzle": https://www.everappz.com/evermusic, besides it seems russians don't trust each other https://www.reddit.com/r/NextCloud/comments/7yytra/nextcloud_audio_player_on_ios/, since I don't even trust myself I got to choose something else.

So far, it is frustrating me that this functionality is not working out of the Box in the Nextcloud iOS app. It's like if you had to pay for Visual Studio Code to activate the Enter key. The changes are quite trivial I have to say: make a list of files in a folder and then play them. But I understand that these projects have already a lot to do and who am I to judge.

A Swift Pull Request?

In a leap of faith I decided maybe it was a good time to contribute to the project and I was already imagining my Pull Request to implement this functionality.

I followed the instructions on how to contribute and afteran absolute madlad ninja workaround to update my dusty XCode: https://stackoverflow.com/questions/58550284/mobiledevice-pkg-untrusted-cannot-open-xcode-after-os-x-update - yeah, really, you need to set the System Date to a previous time lol, I somehow got Carthage to build and run the app. We're in business!

For the record:  I never coded anything in Swift or Objective C, but I do Python and I found out I can use "print". With no idea what was going on in the Xcode Window, I added heaps of print statements EVERYWHERE and figured it out. It had something to do with AVPlayer which is an Audio Video Player for iOS.

I switched it AVQueuePlayer because I wanted to queue all the audio files that were downloaded and that worked well. But still no Next/Previous buttons. I searched online for hours, landed on page 10 of Google with no avail. With time I found out it could have something to do with another class: MPRemoteCommand. So I tried here and there, more print statements and still no buttons, I even followed some youtube tutorials where people implement their own buttons in a storyboard. What? One could think that a functionality like this - Media consumption is trivial to implement with the SDK's provided. But no. MAH BUTTONS!

Very disappointed by this ordeal I managed to implement an automatic "Play next song in Queue" using that said Queue. The changes in the code where minor but I won't submit such a workahackoround to such a good App. Quality matters.

Lessons learned: Adding a Next Song or Previous Song in an iOS media player is ultimately worth selling the App. I wasted hours on this silly venture.

The right solution for me

Back to square one, I decided to use a player that was free and already provided Next/Previous buttons. Which is why I tinkered with VLC a bit. After failing to sync files through SFTP, SMB and the other self hosted options provided (no auto download), I discovered you can use a feature called Wifi Sharing on VLC iOS. What it does is it sets up a local server on the iPhone from which you can upload / download songs directly to the VLC app "space". So whatever you upload it goes into the app. After initial tests it worked like a charm and figuring the curl command was not that big of a deal to push files directly from something like Python.

curl -F file=@"memes_in_b_minor.mp3" http://karims-iphone.local/upload.json > oblivion

All that was left to do is to have some kind of uptime script on a device in my network that checks if my iPhone is connected to my Wifi: Make a request to karims-iphone.local every now and then and if it is online send some audio files. Another Python script handles organizing the audio files by abusing the "Genres" functionality like "Podcast", "JokesForTheWinter" to auto generate Playlists! The VLC app has default grouping by Artist/Albums/Songs/Genres. I decided to use Genres as a filter mechanism for the generated Playlists and Albums for another grouping Mechanism like floating "favorites". And there I have it, a fully automated self-hosted audio management and personal distribution solution. Quite simpler than this setup which involves every possible app in the Universe but it works for the person who implemented it: https://www.reddit.com/r/selfhosted/comments/96kfc9/my_automatic_music_downloading_archiving_and/ but I like it, it is mine and that's my version of escaping.

PS: If someone has a good option for solving this problem or overall improving my litteracy in Swift or Objective C, please let me know. I settled for now, but I won't let my lack of knowledge in iOS App Development like it is.  (っ•́。•́)♪♬