# Any way to create AudioFormatReader from URL directly on iOS?

**URL:** <https://forum.juce.com/t/any-way-to-create-audioformatreader-from-url-directly-on-ios/52653>\
**Category:** MacOSX and iOS\
**Created:** [August 19, 2022, 7:02am UTC](https://forum.juce.com/t/any-way-to-create-audioformatreader-from-url-directly-on-ios/52653 "2022-08-19T07:02:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![playpm](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/playpm/32/14429_2.png) [@playpm](https://forum.juce.com/u/playpm)\
**Post date:** [August 19, 2022, 7:02am UTC](https://forum.juce.com/t/any-way-to-create-audioformatreader-from-url-directly-on-ios/52653/1 "2022-08-19T07:02:28Z")

</div>

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.

```auto
std::unique_ptr<juce::AudioFormatReader> reader
{ 
    mFormatManager.createReaderFor(pathURL.getLocalFile()) 
};

```

---

<div class="post-metadata">

**Author:** ![luzifer](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/luzifer/32/60_2.png) [@luzifer](https://forum.juce.com/u/luzifer)\
**Post date:** [August 19, 2022, 8:46am UTC](https://forum.juce.com/t/any-way-to-create-audioformatreader-from-url-directly-on-ios/52653/2 "2022-08-19T08:46:20Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![playpm](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/playpm/32/14429_2.png) [@playpm](https://forum.juce.com/u/playpm)\
**Post date:** [August 19, 2022, 12:36pm UTC](https://forum.juce.com/t/any-way-to-create-audioformatreader-from-url-directly-on-ios/52653/3 "2022-08-19T12:36:25Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![luzifer](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/luzifer/32/60_2.png) [@luzifer](https://forum.juce.com/u/luzifer)\
**Post date:** [August 19, 2022, 1:28pm UTC](https://forum.juce.com/t/any-way-to-create-audioformatreader-from-url-directly-on-ios/52653/4 "2022-08-19T13:28:55Z")

</div>

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](https://forum.juce.com/t/make-url-bookmark-publicly-accessible/49779)

---

<div class="post-metadata">

**Author:** ![playpm](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/playpm/32/14429_2.png) [@playpm](https://forum.juce.com/u/playpm)\
**Post date:** [August 19, 2022, 1:36pm UTC](https://forum.juce.com/t/any-way-to-create-audioformatreader-from-url-directly-on-ios/52653/5 "2022-08-19T13:36:40Z")

</div>

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.
