How can I get duration of AudioInputStream?
I want to get duraction of an AudioInputStream (in microseconds). How can I easily do that? I found how can I get duration of an audio file:, but can开发者_开发百科't do that, because of encapsulation. The only object I see is the instance of an AudioInputStream class.
getFrameLength()
returns the stream length in frames, getFormat().getFrameRate()
will give you the number of frames per second.
long durationInMillis = 1000 * getFrameLength() / getFormat().getFrameRate();
精彩评论