How to check current time and duration in AudioQueue

后端 未结 3 1389
隐瞒了意图╮
隐瞒了意图╮ 2021-02-06 13:31

How to get total time duration of music in audioQueue. I am using

NSTimeInterval AQPlayer::getCurrentTime()
{
    NSTimeInterval timeInterval =         


        
3条回答
  •  孤城傲影
    2021-02-06 13:40

    For future reference, I am getting a correct time in seconds using a slight modification of Chandan's code:

    int AQPlayer::GetCurrentTime() {
        int timeInterval = 0;
        AudioQueueTimelineRef timeLine;
        OSStatus status = AudioQueueCreateTimeline(mQueue, &timeLine);
        if(status == noErr) {
            AudioTimeStamp timeStamp;
            AudioQueueGetCurrentTime(mQueue, timeLine, &timeStamp, NULL);
            timeInterval = timeStamp.mSampleTime / mDataFormat.mSampleRate; // modified
        }
        return timeInterval;
    }
    

提交回复
热议问题