# Playing Audio over HTTP with Buffering

**URL:** <https://forum.juce.com/t/playing-audio-over-http-with-buffering/10502>\
**Category:** General JUCE discussion\
**Created:** [May 27, 2013, 5:39pm UTC](https://forum.juce.com/t/playing-audio-over-http-with-buffering/10502 "2013-05-27T17:39:06Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![kernelcoder](https://avatars.discourse-cdn.com/v4/letter/k/91b2a8/32.png) [@kernelcoder](https://forum.juce.com/u/kernelcoder)\
**Post date:** [May 27, 2013, 5:39pm UTC](https://forum.juce.com/t/playing-audio-over-http-with-buffering/10502/1 "2013-05-27T17:39:06Z")

</div>

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 - [http://www.rawmaterialsoftware.com/viewtopic.php?f=2&t=8692](http://www.rawmaterialsoftware.com/viewtopic.php?f=2&t=8692) with no responses.

Hints or suggestions are much appreciated.

---

<div class="post-metadata">

**Author:** ![atom](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/atom/32/113_2.png) [@atom](https://forum.juce.com/u/atom)\
**Post date:** [May 27, 2013, 5:53pm UTC](https://forum.juce.com/t/playing-audio-over-http-with-buffering/10502/2 "2013-05-27T17:53:59Z")

</div>

I had the same problem once, i must addmit i never solved it. But some people here pointed me towards the BufferingAudioReader class: [http://rawmaterialsoftware.com/juce/api/classBufferingAudioReader.html](http://rawmaterialsoftware.com/juce/api/classBufferingAudioReader.html)

maybe you’ll have more luck.

---

<div class="post-metadata">

**Author:** ![kernelcoder](https://avatars.discourse-cdn.com/v4/letter/k/91b2a8/32.png) [@kernelcoder](https://forum.juce.com/u/kernelcoder)\
**Post date:** [May 27, 2013, 6:09pm UTC](https://forum.juce.com/t/playing-audio-over-http-with-buffering/10502/3 "2013-05-27T18:09:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jrlanglois](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jrlanglois/32/21372_2.png) [@jrlanglois](https://forum.juce.com/u/jrlanglois)\
**Post date:** [May 27, 2013, 7:02pm UTC](https://forum.juce.com/t/playing-audio-over-http-with-buffering/10502/4 "2013-05-27T19:02:11Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![kernelcoder](https://avatars.discourse-cdn.com/v4/letter/k/91b2a8/32.png) [@kernelcoder](https://forum.juce.com/u/kernelcoder)\
**Post date:** [May 27, 2013, 7:39pm UTC](https://forum.juce.com/t/playing-audio-over-http-with-buffering/10502/5 "2013-05-27T19:39:07Z")

</div>

> [@jrlanglois](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![jrlanglois](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/jrlanglois/32/21372_2.png) [@jrlanglois](https://forum.juce.com/u/jrlanglois)\
**Post date:** [May 27, 2013, 7:48pm UTC](https://forum.juce.com/t/playing-audio-over-http-with-buffering/10502/6 "2013-05-27T19:48:36Z")

</div>

The zip file is not regularly updated; better off getting the bleeding edge via git (see [Jucequake Part 1](http://www.rawmaterialsoftware.com/viewtopic.php?f=12&t=7660#p43290)).

JUCE Git URL: git://juce.git.sourceforge.net/gitroot/juce/juce

Hope this helps!

---

<div class="post-metadata">

**Author:** ![rory](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/rory/32/534_2.png) [@rory](https://forum.juce.com/u/rory)\
**Post date:** [May 27, 2013, 8:18pm UTC](https://forum.juce.com/t/playing-audio-over-http-with-buffering/10502/7 "2013-05-27T20:18:06Z")

</div>

Or if you’re not using git, you can always grab the latest tip as a zip from here:  
[https://github.com/julianstorer/JUCE/archive/master.zip](https://github.com/julianstorer/JUCE/archive/master.zip)

---

<div class="post-metadata">

**Author:** ![kernelcoder](https://avatars.discourse-cdn.com/v4/letter/k/91b2a8/32.png) [@kernelcoder](https://forum.juce.com/u/kernelcoder)\
**Post date:** [May 28, 2013, 9:42am UTC](https://forum.juce.com/t/playing-audio-over-http-with-buffering/10502/8 "2013-05-28T09:42:06Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![symfonysid](https://avatars.discourse-cdn.com/v4/letter/s/82dd89/32.png) [@symfonysid](https://forum.juce.com/u/symfonysid)\
**Post date:** [May 28, 2013, 12:58pm UTC](https://forum.juce.com/t/playing-audio-over-http-with-buffering/10502/9 "2013-05-28T12:58:37Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kernelcoder](https://avatars.discourse-cdn.com/v4/letter/k/91b2a8/32.png) [@kernelcoder](https://forum.juce.com/u/kernelcoder)\
**Post date:** [May 28, 2013, 3:18pm UTC](https://forum.juce.com/t/playing-audio-over-http-with-buffering/10502/10 "2013-05-28T15:18:59Z")

</div>

> [@symfonysid](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![Nexelen](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/nexelen/32/70_2.png) [@Nexelen](https://forum.juce.com/u/Nexelen)\
**Post date:** [February 17, 2016, 10:03am UTC](https://forum.juce.com/t/playing-audio-over-http-with-buffering/10502/11 "2016-02-17T10:03:30Z")

</div>

@kernelcoder Hello. Did you solve this problem?
