-(void)setCurrentTime:(NSTimeInterval)currentTime{
[_lock lock];
/*
获取queue 已经播放的时间
*/
NSTimeInterval playedTime = GetQueueCurrentTime(self);
/*
算出 拖动后的时间 和 之前时间的 时间差
*/
NSTimeInterval nowPlayTime = currentTime - self.currentTime;
/*
计算出 时间的偏移量
*/
_audioSeekOffset = currentTime - playedTime;
/*
一个包需要多少秒
一秒多少帧 / 一个包多少帧
*/
double packetSecond = _fileFormat.mSampleRate / _fileFormat.mFramesPerPacket;
/*
总共用户seek了 多少包
1秒几包 * 多少秒
*/
double packetCount = nowPlayTime * packetSecond;
/*
算出用户想听的分钟的 包的 位置
*/
_inPacketStart = _inPacketStart + floor(packetCount);
[_lock unlock];
}
AudioQueue实现歌曲快进和后退
最新推荐文章于 2022-07-28 20:37:26 发布