AudioInputStream : any way keep track of number of bytes read from source stream?
I'm using JavaZoom's mp3spi-1.9.5 and jl-1.0.1 to play MP3 files. This works fine, but I'm having a little trouble tracking the "progress" of a stream (measured in bytes)
I need to play an InputStream from a remote file and I need to know how many bytes the application has read and "processed" from the original stream. I do not need to know how long the stream is.
What I've done now is to get a stream using AudioSystem.getAudioInputStream(url). However, I believe the bytes i read from that stream is the number of "decoded"/"uncompressed" bytes, and does not reflect the real number o开发者_开发问答f bytes read from the stream.
Does anyone have an idea as to how I can keep track of the "real" number of bytes read from the original stream?
When using JavaZoom's libraries, an AudioInputStream will be an DecodedMpegAudioInputStream when dealing with MP3's. By casting the AudioInputStream to an DecodedMpegAudioInputStream, you can get the number of bytes read by invoking properties() and getting the key "mp3.position.byte".
精彩评论