audiotrack - Duration of audio file with Libvorbis for Android -


i'm using this library read ogg files android. since i've been taking c++ code , java code, haven't seen way retrieve duration or number of pcm samples after decoded. contains class audiotrack haven't been able retrieve data.

is there workaround can see duration?

thank in advance.

if know number of samples n, samplerate sr , number of channels c, duration t in ms is:

t = (n * 1000 / sr) / c 

example:

123456 stereo samples @ 44100hz = 1399 ms

9000 mono samples @ 8000hz = 1125 ms

audiotrack contains getters retrieve samplerate , number of channels in case don't have information. since got decoded data, should know number of samples.


Comments