AVAudioSession setActive:NO 不恢复 iPod 播放
在我的 iOS 应用程序中,我首先在 iPod 中启动一首歌曲,然后启动我的应用程序。我在我的应用程序中按下一个按钮,并调用
AVAudioSession * audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryRecord error:&err];
[audioSession setActive:YES error:&err];
这两个按钮都成功。然后我开始使用音频队列进行录音,这也有效。但当我完成录音后,我打电话
AVAudioSession * audioSession = [AVAudioSession sharedInstance];
[audioSession setActive:NO error:&err];
……这也成功了。
问题是:我希望 iPod 的音乐能够恢复播放,但事实并非如此。我是不是忘记了什么?没有委托事件,因此不会中断。
In my iOS app, I first start a song in the iPod, then start my app. I push a button in my app, and call
AVAudioSession * audioSession = [AVAudioSession sharedInstance];
[audioSession setCategory:AVAudioSessionCategoryRecord error:&err];
[audioSession setActive:YES error:&err];
both of which succeed. I then start recording using audio queues, and that works too. But then when I'm done recording, I call
AVAudioSession * audioSession = [AVAudioSession sharedInstance];
[audioSession setActive:NO error:&err];
... which also succeeds.
The rub: I would expect the iPod's music to resume playing, but it doesn't. Am I forgetting something? There are no delegate events, so no interruptions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您没有说 AVAudioSessionSetActiveFlags_NotifyOthersOnDeactivation,因此 iPod 音乐应用程序不会收到您停用的通知。
然而,事情可能还不止于此。一般来说,其他应用程序的功能并不取决于您。如果您想要播放 iPod 音乐,请使用 MPMusicPlayerController。
You didn't say AVAudioSessionSetActiveFlags_NotifyOthersOnDeactivation, so the iPod music app wasn't notified that you deactivated.
However, there may be even more to it than that. In general, what some other app does isn't up to you. If you want to make iPod music play, use MPMusicPlayerController.