使用AVPlayer播放音频文件的偏移量

问题描述:

我使用AVPlayer播放iphone上的音频文件。使用AVPlayer播放音频文件的偏移量

我想要的是,当我在特定时间停止播放音频并再次开始播放音频时,音频应从停止播放它的位置开始播放。

任何人都知道如何用AVPlayer实现这一点?

+0

看到http://*.com/questions/8676461/how -to-恢复-avaudioplayer-后的间断的背景 –

如果你想在同一时间,无需关闭应用程序,然后使用此代码

AVAudioPlayer发挥*播放器;

[player pause];

之后

[player play];

找出你在一个轨道时播放暂停

time = CMTimeGetSeconds(self.av_Player.currentTime); 
[self.av_Player pause]; 

然后跳转到该位置再次

newTime = CMTimeMakeWithSeconds(time, 6000); 
toleranceVal = CMTimeMakeWithSeconds(0.1, 6000); 
[self.av_Player seekToTime:newTime toleranceBefore:toleranceVal toleranceAfter:toleranceVal]; 
[self.av_Player play];