我有以下代码:
AVPlayerItem *currentItem = [AVPlayerItem playerItemWithURL:soundURL];
[self.audioPlayer replaceCurrentItemWithPlayerItem:currentItem];
[self.audioPlayer play];
哪里soundURL
是remoteURL
。它工作正常。完美地AVPlayer
播放音乐。我有一个进度条,我正在根据播放器的当前时间对其进行更新。
一切正常。我的问题是当我将进度条从新位置向前拖动audioplayer
时,但如果我拖动progressbar
它不会从新位置开始,实际上它会从以前的位置恢复。这是我的进度条拖动开始和停止代码:
- (IBAction)progressBarDraggingStart:(id)sender
{
if (self.audioPlayer.rate != 0.0)
{
[self.audioPlayer pause];
}
}
- (IBAction)progressBarDraggindStop:(id)sender
{
CMTime newTime = CMTimeMakeWithSeconds(self.progressBar.value, 1);
[self.audioPlayer seekToTime:newTime];
[self.audioPlayer play];
}
谁能帮我解决这个问题?