コントローラが1つあります。最初に私はオーディオ1を再生します。私はこのコードを使用します:AVAudioSessionでオーディオを一時停止して再生する
- (void)viewDidLoad
{
//code to not turn off audio with using mute switch
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
[[AVAudioSession sharedInstance] setActive: NO error: nil];
//code to play audio
NSString *soundFilePath = [NSString stringWithFormat:@"%@/%@.mp3",[[NSBundle mainBundle] resourcePath], @"sound"];
NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
_player = [[AVAudioPlayer alloc] initWithContentsOfURL:soundFileURL error:nil];
_player.numberOfLoops = -1;
[_player play];
}
しかし、私は私のアプリケーションのオーディオを一時停止しないで非表示にします。アプリを隠すとオーディオを一時停止し、アプリがフォアグラウンドになると一時停止して再生したいどうやってするの?
(https://stackoverflow.com/questions/6635604/play-pause-with-the-same-button-avaudioplayer)[再生/同じボタン\ [AVAudioPlayer \]で[一時停止]の可能性のある重複 – kb920