我使用此代碼來循環播放我的Sprite Kit遊戲中的一首歌曲,但是當我離開應用/遊戲時,歌曲繼續播放,並且我不知道如何停止歌曲下車遊戲:聲音一直在Sprite Kit遊戲上播放
url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"deep-blue-sea" ofType:@"wav"]];
_sound = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil];
_sound.delegate = self;
_sound.numberOfLoops = -1;
[_sound play];
請有人可以幫我怎麼做嗎?
謝謝,但我必須在AppDelegate.h中實現AVAudioPlayer框架以使用stop方法嗎?我在SKScene中聲明瞭_sound屬性,我如何在AppDelegate中使用它? – 2015-02-11 00:38:24
@FacundoSchiavoni看我的編輯。 – NobodyNada 2015-02-11 00:47:03