问题
I have used xuggler
to play audio files other than wav,au,aiff
. Since xuggler
performs audio decoding at low level it is very hard to write a method that both forwards and rewinds the audio being played . ( while decoding xuggler analyzes each data packet and then sends it to play)
One way could be read bunch of packets at a time and then send the next packet to play.This way the effect of forwarding audio can be felt . But i don't know how to implement this method
Moreover this is not the best way i can forward the data.
Are there any direct methods to forward and rewind audio ? If not direct what is the algorithm , steps to do this ?
回答1:
Have you looked at the seekKeyFrame()
method in IContainer
? See here. On seek, you could just flush the dataline and then on execution of the method the container should jump to the given location.
If you want to do it by a percentage call, then getDuration() gets the entire length of the stream (if available.) You can then work out accurate timestamps from there.
来源:https://stackoverflow.com/questions/6924474/forwarding-and-rewinding-audio-in-xuggler