Not able to play song while streaming


#1

Hi,
I am trying to download a song from URL, i am streaming the song, but when i am playing it, it plays initial few seconds and stops.

Thanks in advance for your help!


#2

Well, a few details might help here…?


#3

Hi,

I am creating a tread which will download a song from given URL. In thread I am using BufferedInputStream for input stream from URL class. FileOutputStream class object is used to read data from an input stream and write it to this stream. This will downloads the song properly. After this I wand to play the song, it plays the initial few seconds and then stops. One more thing is that before the while loop in the thread, I copied some part to the output stream, and I think juce plays only that portion of the song, this I conformed by coping more song and it plays for few more seconds.

May this will help you to understand my problem.

Thanks for your reply…


#4

Well yes - the classes that read from a file aren’t designed to expect the file to be continuously changing! When you open a file, it’ll check the length, and play that much of the file - if the file changes the best you can hope is that it’ll only play the initial section, but it could also cause horrible problems/crashes if the position of data inside the file changes while it’s being actively read (e.g. if it was a compressed format).

I’m actually a bit surprised that you’re managing to read and write at the same time without the file operations failing…