Sadeesh Kumar wrote:
In libmad, when the song is playing, how can i jump to different differnt location and start to play from that location?. I find it, there is no direct easy interface to do this.
To jump to a new location using the low-level API:
1. Seek to an approximate location in the file and load your buffer with data from the new position.
2. Call mad_stream_buffer() to update the stream pointers for the modified buffer.
3. Call mad_frame_mute() and mad_synth_mute().
At this point you can simply resume decoding. However, to avoid any unpleasant burps in the audio, unless you have seeked to the very beginning of the file, it is best to:
4. Call mad_frame_decode() successfully at least twice. Note that the first few calls will probably yield recoverable decoding errors which you can safely ignore.
5. Call mad_synth_frame() once and discard the resulting PCM.
The MAD plug-in for Winamp does all of this if you're looking for an example.
Cheers, -rob