VLC for Android shows playlists as empty

I make and manage my playlists using NCMPCPP and MPD (guide to setting up NCMPCPP here) which means all my playlists are in .m3u format and have paths relative to whatever directory I set as my mdp_music_dir. I’ve been able to use these playlists in most of the music player apps available on the Google Play store, but VLC just doesn’t want to behave and lists all of my playlists as having zero tracks.

Here’s how my playlists look:

Grateful Dead - American Beauty/Ripple.mp3
Cat Stevens - Tea for the Tillerman/Father And Son.mp3
Fleetwood Mac - Rumours/Go Your Own Way.mp3
Van Morrison - The Best Of/Moondance.mp3
Red Hot Chili Peppers - Californication/Scar Tissue.mp3

When I move all the playlists onto the SD card in my Android phone the songs play using Pulsar and most other music players but not in VLC, which lists each playlist but says they have no tracks.

Why are my playlists showing as empty on VLC for Android?

Because VLC requires an absolute path to each track but my playlists have a relative path (relative to the location of all my music). It’s surprising that VLC behaves like this because it prevents sharing playlists between machines which seems like a pretty common use case to me.

Where are VLC playlist files stored?

Playlists created with the VLC app aren’t stored as files on your device so don’t bother trying to find them and use them as a template for your playlists. Instead they are stored in the app’s database, I think it’s a sqlite database and even though I’m familiar with using them I don’t think it should be necessary to go poking around so deep inside any app just to import a simple playlist.

How to get the playlists working on VLC

Update the tracks in your playlists with an absolute path to get VLC working with your imported playlists. Here’s how my updated playlists look:

/storage/B012-4172/my-music/Grateful Dead - American Beauty/Ripple.mp3
/storage/B012-4172/my-music/Cat Stevens - Tea for the Tillerman/Father And Son.mp3
/storage/B012-4172/my-music/Fleetwood Mac - Rumours/Go Your Own Way.mp3
/storage/B012-4172/my-music/Van Morrison - The Best Of/Moondance.mp3
/storage/B012-4172/my-music/Red Hot Chili Peppers - Californication/Scar Tissue.mp3

Finding that path /storage/B012-4172 took me way longer than it should have done. I expected it to be in the phone’s settings somewhere under the storage section but it wasn’t there. I then tried using the built in file browser to ‘get info’ of a file saved on the SD card but that didn’t show it either. Next I downloaded Google’s official file browser but that gave me even less useful info. Eventually I found it using the “Material Files” file browser app which lets you ‘get info’ on the SD card to see the path.

How to edit the paths in your playlists? I’m sure a single line of bash can do this but I like Ruby so here’s a Ruby script I wrote to create an “Android for VLC compatible” version of all my playlists and save it somewhere temporarily. I then use rSync to update my phone and delete the temporary playlists folder once I’m done.

require 'fileutils'

LOCAL_PLAYLISTS_DIR     = "/home/planetroast/playlists"
LOCAL_TEMP_DIR          = "/tmp/vlc-compatible-playlists"
PHONE_MUSIC_DIR         = "/storage/B012-4172/my-music"

Dir.glob("#{LOCAL_PLAYLISTS_DIR}/*.m3u") do | playlist |

    # Load contents of playlist into an array
    file_data = File.read(playlist).split("\n") # Array of tracks
    name = File.basename(playlist) # Name of the playlist including .m3u

	# Create directory
	FileUtils.mkdir_p LOCAL_TEMP_DIR

    # Create new file with updated path to the track
    phone_playlist = File.open("#{LOCAL_TEMP_DIR}/#{name}", "w")
    file_data.each do | track |
        phone_playlist.write "#{PHONE_MUSIC_DIR}/#{track}\n"
    end

    # Close file connection
    phone_playlist.close

end