컨트롤러가 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];
}
그러나 내 앱을 숨길 때 일시 중지되지 않습니다. 앱을 숨기면 오디오를 일시 중지하고 앱이 포 그라운드로 오면 일시 중지 지점에서 재생하고 싶습니다. 그것을하는 방법?
가능한 복제 [PLAY/동일한 버튼 \ 일시 정지와 [AVAudioPlayer \] (https://stackoverflow.com/questions/6635604/play-pause-with-the-same-button-avaudioplayer) – kb920