Read Access Violation


As you can see from the screenshot I’m getting Read Access Violation from the following line of code:

auto* reader = formatManager.createReaderFor(audioURL.createInputStream(false));

I’m not sure what is causing it and how to fix it. Please help!

Looks like createInputStream may have failed and so returned a nullptr… is the URL valid?

@ImJimmi thanks for the reply.

Yes - when I print audioURL.toString(); it shows file:///C%3A/Users/myusername/Music/Clocks.mp3 which is valid URL. Not sure why it is complaining.

have you stepped into it to see if the stream is being created properly?

usually juce::File is used for directories on your computer and juce::URL is more for internet connections. idk if that makes a difference here but it’s worth a try i think

What’s the call stack leading to the error?

That the “this” pointer has that particular looking value, is a bit suspicious. Is your DJAudioPlayer object properly initialized?

@xenakios when you asked >>Is your DJAudioPlayer object properly initialized? >> made me realise that when calling player->loadURL(URL{ chooser.getResult() }); , I need to have the DJAudioPlayer object (player) initialised in the constructor of the class where it gets called. Not initialising and calling it is causing the problem.

Thank You