Seamless audio player

does anyone have some tips on how to build an audio player that can play from one file to the other seamlessly? My application requires to do this without any gaps. I know I should use buffering, but how do I accomplish this with Juce? The problem being that I need to buffer while playing, pre-loading the next file.


How about having two buffer and a pre-loading thread.

Suppose you are playing song1 and the data is stored in buffer1. Say after certain duration you can start “loading thread” which would in-turn read songs2 and load it into buffer2. After song1 has been completely played, use buffer2 to play. Have some kind of variable to indicate which buffer is free and use that buffer for pre-loading the next song.

Am not very sure whether it’s a good idea. Hopefully somebody else would suggest other ideas.

The correct way to do it is to write an ‘edit’ AudioSource that takes a series of other sources, and streams them in order. Then you’d pass that source to a buffering audio source. I should really have written something to do this, but never quite got around to it - other people must have done one though…

he wants to create a playlist?

yes, sort of

getCurrentPosition() of class AudioTransportSource
sampleRate and lengthInSamples of class AudioFormatReader

player_totalTime = double (AudioFormatReader-> lengthInSamples) / double (AudioFormatReader-> sampleRate);