Reading wav from web for playing audio?


#1

Hi!

The AudioDemo accepts local files to play from the disk. Is there a way to read files from the web given a URL or do I need to download them first and then pass the temporary file to play?

Do we have any sample code to help with this?


#2

I tried using a URL instead of file to read from the web and I got

0x8001010D: An outgoing call cannot be made since the application is dispatching an input-synchronous call.

Anything obvious?


#3

I don’t really know, but I’m guessing the file operation blocks program execution in a way that is not well suited for downloads.

I would go with downloading first and playing after. I’m sure you can stream it in some way, but I don’t think file operations is where you want to look.


#4

would something like the following do the trick?

class buf: public BufferedInputStream, public URL {
DownloadThread* thr;
buf(String url) {
// read URL and create file name
// start a DownloadThread and pass file name to it
// run the thread
}
// implement getBytes etc by checking the thread state and returning bytes from downloaded file

}

class DownloadThread: public Thread {
// implement downloading the file
}