请记住,我是一个新手,因此不是很有经验:我有几个音频文件播放由按钮触发,每次按下按钮,所有其他声音停止。现在我想要创建一个按钮来停止当前播放的任何内容。此外,每次按下其中一个按钮,音乐都不会从头开始,而是从中断的时间点开始。提前谢谢,这是一个片段:
- (IBAction)playSound1 {
if ((self.sound2Player.playing) || (self.sound3Player.playing)|| (self.sound4Player.playing)||(self.sound5Player.playing)||(self.sound6Player.playing)||(self.sound7Player.playing))
[self.sound2Player stop];
[self.sound3Player stop];
[self.sound4Player stop];
[self.sound5Player stop];
[self.sound6Player stop];
[self.sound7Player stop];
[self.sound2Player stop];
[self.sound1Player play];
答案 0 :(得分:1)
请使用此
- (IBAction)stopSound
{
[self.sound1Player stop];
[self.sound2Player stop];
[self.sound3Player stop];
[self.sound4Player stop];
[self.sound5Player stop];
[self.sound6Player stop];
[self.sound7Player stop];
[self.sound2Player stop];
}
如果您再次想要停止播放,那么为什么要停止播放器使用[avPlayer pause]
来代替[self.avPlayer stop];
,那么当您再次播放时,它们将从您停止播放的位置开始。< / p>