gpt4 book ai didi

ios - 当应用程序在后台运行时,freestreamer无法在通话结束后继续播放音乐(实际上没有声音)

转载 作者:行者123 更新时间:2023-12-03 02:02:18 26 4
gpt4 key购买 nike

我尝试使用freestreamer播放音乐,当应用程序在后台运行时,可以停止通话,但是音乐可以停止,但是如果通话结束(CTCallStateDisconnected),音乐无法再次恢复,则可以在通话结束时捕获状态(AVAudioSessionInterruptionTypeEnded)在FSAudioStream函数中

    } else if ([interruptionType intValue] == AVAudioSessionInterruptionTypeEnded) {
if (self.wasInterrupted) {
self.wasInterrupted = NO;

@synchronized (self) {
[[AVAudioSession sharedInstance] setActive:YES error:nil];
fsAudioStreamPrivateActiveSessions[[NSNumber numberWithUnsignedLong:(unsigned long)self]] = @"";
}

if (self.wasContinuousStream) {
/*
* Resume playing.
*/
[self play];
} else {
/*
* Resume playing.
*/
[self playFromOffset:_lastSeekByteOffset];
}
}
}

而且该应用程序还可以在后台捕获kFsAudioStreamPlaying状态,这意味着再次开始播放音乐,但是我根本听不到音乐!有人知道如何解决这个问题吗?
顺便说一句,我也设置
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];

支持后台播放。

2015年5月27日更新:

我已经阅读了有关 Background audio doesn't resume after a call的内容,在这种情况下,该中断通知已在代码中捕获,还可以检测到通话结束状态并重新启动音乐,但根本没有声音

最佳答案

很高兴,解决了这个问题:在后台,我们应该添加一些代码来支持后台播放

            @synchronized (self) {
[[AVAudioSession sharedInstance] setActive:YES error:nil];
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
fsAudioStreamPrivateActiveSessions[[NSNumber numberWithUnsignedLong:(unsigned long)self]] = @"";
}

这将解决这个问题!

关于ios - 当应用程序在后台运行时,freestreamer无法在通话结束后继续播放音乐(实际上没有声音),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30457857/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com