Kathan Shah
Kathan Shah

Reputation: 1755

get current position / time of file in superpowered decoder while decoding

While decoding file using superpowered i get samplePosition but i want current position in miliseconds / seconds. samplePosition is the current position in samples. but what i actually need is current position in milliseconds. while decoding i want to mute / unmute at certain millisecond positions in audio file.

while (true) {

    currentSamplesDecoded = decoder->samplesPerFrame;
    status = decoder->decode(intBuffer, &currentSamplesDecoded);

    baseCurrentPosition = decoder->samplePosition;

    // What i want is :- 
    // currentMiliseconds = decoder-> how to get current position in Miliseconds

}

Thanks in Advance

Upvotes: 0

Views: 59

Answers (1)

Kathan Shah
Kathan Shah

Reputation: 1755

Math!, I was not sure about the terms of samplePosition and durationSamples

decoder->durationSeconds * ((double)decoder->samplePosition / (double)decoder->durationSamples)

So it seems samplePosition divide by durationSamples gives % progress

Thank You

Upvotes: 0

Related Questions