How to check current time and duration in AudioQueue

后端 未结 3 1388
隐瞒了意图╮
隐瞒了意图╮ 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:53

    NSTimeInterval  AQPlayer::getTotalDuration()
    {   
        UInt64 nPackets;
        UInt32 propsize = sizeof(nPackets);
    
        XThrowIfError (AudioFileGetProperty(mAudioFile, kAudioFilePropertyAudioDataPacketCount, &propsize, &nPackets), "kAudioFilePropertyAudioDataPacketCount");
        Float64 fileDuration = (nPackets * mDataFormat.mFramesPerPacket) / mDataFormat.mSampleRate;
    
        return fileDuration;
    }
    

提交回复
热议问题