Any way to create AudioFormatReader from URL directly on iOS?

I’m trying to follow the official document, using URL to open a local file directly, but got no luck to success, any suggestions?

This is my code, the pathURL is a URL, not a converted string.

std::unique_ptr<juce::AudioFormatReader> reader

Use AudioFormatManager::createReaderFor but with URL’s createInputStream method.

1 Like

Thanks! It worked pretty well.

Btw, do you know how to save the URL to a property of AudioProcessorValueTreeState, so it will be saved and called for reopening a project? I tried to save URL to a property but it only accept juce::var, not URL.

You can serialize it to a string. However it won’t be accessible anymore this way after the app restarted. Unfortunately JUCE made access to URL’s bookmark data private which is the thing you’d really want to serialize. See Make URL::bookmark publicly accessible

Oh, that’s sad, the problem I got is just like what you said, after app killed and restart, the URL won’t work anymore.