iphone - AVAudioPlayer 与 MPMusicPlayerController

标签 iphone objective-c audio avaudioplayer

我使用 MPMusicPlayerController 在我的应用程序中播放音乐,使用 iPodMusicPlayer(也尝试过 applicationMusicPlayer)。当我使用 AVAudioPlayer 播放声音时,来自 MPMusicPlayerController 的音乐将停止。有没有办法让 MPMusicPlayerControllerAVAudioPlayer 同时播放声音?

最佳答案

嘿,在网上找到了解决方案。

将这两行写在某个地方,我在 application:didFinishLaunchingWithOptions 中做到了

// Set sounds not to stop music
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryAmbient error: nil];
[[AVAudioSession sharedInstance] setActive: YES error: nil];

必须承认我没有深入研究细节,但它确实有效...

祝你好运!

奥德。

关于iphone - AVAudioPlayer 与 MPMusicPlayerController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3224269/

相关文章:

objective-c - 对象-C : Constantly observe changes to a property(double value) to trigger if's

audio - 无法将语音转换为文本

iphone - AVAudioPlayer 的问题

ios - 如何为不同的屏幕尺寸设置不同的字体,例如iPhone 6s和iPhone SE

ios - 在应用内购买 iOS 中恢复交易

iphone - 使用 NSURLConnection 的哪个委托(delegate)

iOS : Losing Bluetooth Connection

vb.net - 声音样本的数学分析(作为数字数组)

iphone - Google Plus 共享,来自 ios 的点赞按钮

ios - 如何在 iPhone 应用程序的密码字段中隐藏文本?