Ios 当应用程序加入agora.io频道时,AVAudioPlayer会自动停止

Ios 当应用程序加入agora.io频道时,AVAudioPlayer会自动停止,ios,objective-c,avaudioplayer,avaudiosession,agora.io,Ios,Objective C,Avaudioplayer,Avaudiosession,Agora.io,当用户点击我的应用程序中的call button/Joinchane(Agora)时,我正在添加声音 [self.agoraKit joinChannelByToken:self.userManager.agoraToken channelId:self.userManager.channelName info:nil uid:[self.userManager.UID integerValue] joinSuccess:^(NSString *channel, NSUInteger u

当用户点击我的应用程序中的call button/Joinchane(Agora)时,我正在添加声音

    [self.agoraKit joinChannelByToken:self.userManager.agoraToken channelId:self.userManager.channelName info:nil uid:[self.userManager.UID integerValue] joinSuccess:^(NSString *channel, NSUInteger uid, NSInteger elapsed) {
        NSString *path = [[NSBundle mainBundle] pathForResource:@"ringing-sound-jalebi" ofType:@"mp3"];
        NSURL *soundFileURL = [NSURL fileURLWithPath:path];
        self.audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:soundFileURL error:nil];
        self.audioPlayer.delegate = self;
       [self.audioPlayer play];
     }];

但我收到了“AVAudioSession.mm:997:-[AVAudioSession setActive:withOptions:error::停用运行I/O的音频会话。在停用音频会话之前,应停止或暂停所有I/O”错误。有人能帮我解决这个问题吗?

当你加入通话时,Agora SDK似乎会自动停用任何现有的AVAudioSessions,以确保你能听到与你通话的人的声音。我建议改为通过Agora播放声音


谢谢你的解决方案。现在,如何停止音频??使用播放效果的id调用pauseEffect:或stopEffect:。
// Plays an audio effect file.
int soundId = 1; // The sound ID of the audio effect file to be played.
NSString *path = [[NSBundle mainBundle] pathForResource:@"ringing-sound-jalebi" ofType:@"mp3"]; // The file path of the audio effect file.
int loopCount = 1; // The number of playback loops. -1 means an infinite loop.
double pitch = 1; // Sets the pitch of the audio effect.
double pan = 1; // Sets the spatial position of the audio effect. 0 means the effect shows ahead.
double gain = 100; // Sets the volume. The value ranges between 0 and 100. 100 is the original volume.
BOOL publish = true; // Sets whether to publish the audio effect.
[self.agoraKit playEffect:soundId filePath:path loopCount:loopCount pitch:pitch pan:pan gain:gain publish:publish];