我用 AVAudioPlayer 播放了一个 10 秒的 wav 文件,效果很好。现在我要在第 4 秒停止 wav,然后从第 1 秒开始再次播放。
这是我尝试过的代码:
NSString *ahhhPath = [[NSBundle mainBundle] pathForResource:@"Ahhh" ofType:@"wav"];
AVAudioPlayer *ahhhhhSound =[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:ahhhPath] error:NULL];
[ahhhhhSound stop];
[ahhhhhSound play];
我得到的是,wav 在第 4 秒停止,但是当我再次运行 [XXX play] 时,wav 继续播放第 5 秒,而不是从头开始播放。
我怎么能做到这一点?任何帮助将不胜感激。