AVFoundation AVAudioPlayer 停止正在暂停 - Objective-C

AVFoundation AVAudioPlayer stop is pausing - Objective-C

显示此代码相当困难,因为它在代码中不明显。我有一些操作,例如 -(IBAction)PlaySound1:(id)sender;-(IBAction)PlaySound2:(id)sender; 以及音频文件。我的声音工作正常。我也有-(void)Stop;。当按下播放声音 1 时,它调用停止方法并停止声音 2。与声音 2 相同。

我遇到的问题是当您播放声音 1 并停止声音 2 时,当您播放声音 2 时它会从停止的地方开始。

在我的 (void) 里面我有 [PlaySound1 stop] //and [PlaySound2 stop]

如果有人能提供帮助那就太好了。如果有什么不清楚的地方,请对此发表评论,我会尝试更好地解释它。

谢谢 :)

停止 AVAudioPlayer 不会重置播放头。

The stop method does not reset the value of the currentTime property to 0. In other words, if you call stop during playback and then call play, playback resumes at the point where it left off.

要从头继续播放,请在调用播放之前将 currentTime 属性 设置为 0.0。

例子-

playSound2.currentTime = 0.0;
[playSound2 play];