问题描述
我已经用我的应用程序内的音乐演奏 MPMusicPlayerController
,使用 iPodMusicPlayer
(也试过applicationMusicPlayer)。当我使用 AVAudioPlayer
我的音乐播放声音我的 MPMusicPlayerController
将停止。有没有办法有 MPMusicPlayerController
和 AVAudioPlayer
播放声音同时?
I have music playing within my application using a MPMusicPlayerController
, using iPodMusicPlayer
(also tried applicationMusicPlayer). When I play a sound using AVAudioPlayer
my music from my MPMusicPlayerController
will stop. Is there a way to have the MPMusicPlayerController
and the AVAudioPlayer
play sounds simultaneously?
推荐答案
嘿,在网上找到了解决方案。
Hey, found the solution on the web.
地方写这两条线,我做到了在应用中:didFinishLaunchingWithOptions
Write these 2 lines somewhere, I did it in application:didFinishLaunchingWithOptions
// Set sounds not to stop music
[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryAmbient error: nil];
[[AVAudioSession sharedInstance] setActive: YES error: nil];
必须承认我没有深入到细节,但它的工作原理...
Must admit I didn't delve into the details, but it works...
祝你好运!
俄德。
这篇关于AVAudioPlayer与MPMusicPlayerController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!