Creating an M3U file with Avalonia cross-platform (Windows and Android)

23 hours ago 1
ARTICLE AD BOX

I cannot get my head around this and Google hasn't given me the right answer either (or it is so plain obvious that I keep missing it).

I'm trying to create an M3U file of music files on the system in an Avalonia cross-platform app. On desktop (Windows) that's easy enough, write the paths to the files into an M3U file and open it in for example VLC to play it. On Android however, I get the content:// URIs, which don't work in M3U on Android. Checking how VLC does it when saving a playlist, it actually stores ///storage/emulated/0/... files (the actual paths to the files), which VLC is happy to play (as long as the files exist and VLC has the permissions to read of course).

I have tried every method of IStorageItem, IStorageProvider, IStorageBookmarkItem, but no conversion exists from one to the other.

How to go about this, do I need to somehow convert the content:// URIs to ///storage URIs? Using native Android functions maybe? Or am I thinking in the wrong direction?

So:

var files = await storageProvider.OpenFilePickerAsync(new FilePickerOpenOptions { Title = title, AllowMultiple = false, FileTypeFilter = fileTypes, SuggestedFileType = suggestedFileType, SuggestedFileName = suggestedFilename, SuggestedStartLocation = storageFolder, });

gives me files[0], which is an IStorageFile instance, which on Android is a content:// URI when I pick a music file. That I like to convert to an actual file path on Android, if that is the correct way to do this.

Read Entire Article