Playing Audio over HTTP with Buffering

Hi All,

I’m creating an app which needs to play audio file (mp3, wav, aiff etc) from local file-system as well as from web. It works fine for local file-system on Windows and Mac. However, when I’m feeding an InputStream from a url (through URL::createInputStream & AudioFormatManager::createReaderFor), its getting hanged, or, sometimes responses the UI and playing after a long time (rarely) and sometimes not (most of the time).

So what I’m doing for now is downloading the content from web and keeping in memory-stream and feeding that stream when downloading is done.

What I want is the player will play audio from web with buffering (will be able to play the amount already downloaded and while the remaining content is downloading).

I have found a somewhat similar question here - with no responses.

Hints or suggestions are much appreciated.

I had the same problem once, i must addmit i never solved it. But some people here pointed me towards the BufferingAudioReader class:

maybe you’ll have more luck.

Thanks for so quick reply. I’m going to read about the class (and back with my results).

UPDATE: Unfortunately I failed to find that class in any of the JUCE modules in my file system. My JUCE version is 2.0.21.

The class has been around since March, looking at the git logs… No idea what version JUCE was at that point, but seems like a chance to update your instance of the repository (JUCE is at 2.0.40 now).

Sorry if I’m wrong but I just downloaded the latest codebase and failed to find the class.

The zip file is not regularly updated; better off getting the bleeding edge via git (see Jucequake Part 1).

JUCE Git URL: git://

Hope this helps!

Or if you’re not using git, you can always grab the latest tip as a zip from here:

Yeah, I found that file after git cloning, thanks. But how that class can help to solve my problem? That class also takes an AudioFormatReader instance in the constructor and the hanging happens when I call AudioFormatManager::createReaderFor(InputStream*) method to create that AudioFormatReader instance?

How big are the files you need to play? I looked at those classes with the same purpose in mind a few months ago and wasn’t able to get it to work, but I only needed to play 30 second audio samples. So, I just downloaded the files to the local harddrive first rather than streaming them off the web, and that worked fine.

The size is about 10 MB maximum. I’m doing same right now as you but its not about the size but perfection and more about doing in right way.

@kernelcoder Hello. Did you solve this problem?