I’m writing a BlackBerry app, that needs to play audio files from a URL, without downloading them first (streaming via HTTP)
The javax.microedition.media.Player class can be used with a URL, like so:
Player player = javax.microedition.media.Manager.createPlayer(audioUrl); player.realize(); player.prefetch(); player.start();
Unfortunately, when I run the code in a simulator, the audio sounds choppy, and skips and freezes throughout the song.
After a day or so of digging and trying a few different solutions (like my own version of PipedInput/OutputStream, or the DataSource and SourceStream solution proposed by BlackBerry) I found out that there really isn’t a problem at all. The choppiness occurs only in the simulator. Still not sure what the cause is, but it does not appear to be related to preloading/buffering. Bottom line is, the default method, as in the source code above, works just fine on the device.