简体   繁体   中英

AVAudioSession - Seems to Think I'm Always Playing Audio

I'm using background audio in my iOS app. When the app launches there is no audio playing, but the status bar shows the play icon & the pause button is shown on the remote control. The app seems to think I'm already playing audio.

viewDidLoad

[[AVAudioSession sharedInstance] setCategory: AVAudioSessionCategoryPlayback error: nil];
[[AVAudioSession sharedInstance] setActive: YES error: nil];

viewWillAppear

[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
[self becomeFirstResponder];

Any ideas why iOS thinks I'm playing audio? How can I fix this?

I'm receiving the remote events with no problem.

I figured it out... I'm using the Finch iOS audio library & part of its initialization convinces iOS that audio is playing.

FIFactory *soundFactory = [[FIFactory alloc] init];
FISoundEngine *engine = [soundFactory buildSoundEngine];
[engine activateAudioSessionWithCategory:AVAudioSessionCategoryPlayback];
[engine openAudioDevice];

I would like to use Finch & would like to preload my sound effect so it's ready to go. Unfortunately this doesn't appear to be possible without the play icon showing up.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM