seek in audio file based on time
Seeking through an audio file based on the packet level is simple. One just has to change currentPacket when filling the next buffer:
AudioFileReadPackets(_audioFile, false, &numBytes, _packetDescs, _currentPacket, &numPackets, buffer->mAudioData);
But what if you want to seek to position 10s from the beginning of the file? For the CBR files this should be simple to calcula开发者_如何转开发te - but what about VBR files?
The solution is to use the ExtAudio* API. One can convert the input files to LPCM on the fly and then seeking becomes trivial.
精彩评论