Tonester
Tonester

Reputation: 238

Removing Play icon in status bar when using AVAudioPlayer

I have an iPhone app that plays tracks through an AVPlayer, and separately want button click sounds. I first used AVAudioPlayer for the clicks and this works fine except I don't want the 'Play' icon in the status bar to appear every time the user clicks a button and the click sample is played.

I turned my attention to System Sounds, which I read has limitations in that you cannot directly set the volume. However, I am seeing strange volume behaviour which makes me wonder if I can:

NSURL *clickURL = [[NSBundle mainBundle] URLForResource:@"click" withExtension:@"wav"];
SystemSoundID clickSoundID;
AudioServicesCreateSystemSoundID((CFURLRef)clickURL, &clickSoundID);    
AudioServicesPlaySystemSound(clickSoundID);

If I click a button before playing a track the volume is set to the phone ringer volume. However, after playing a track using AVPlayer the volume is set to the player volume (as I would like it to be).

Any ideas how I can make the System Sound sample take on the app volume level regardless of if AVPlayer has been in action first? Alternatively is there a way to disable play icon notifications in the status bar?

Upvotes: 0

Views: 906

Answers (1)

Benjamin Mayo
Benjamin Mayo

Reputation: 6679

You need to set the correct AVAudioSession. There is one called solo ambient which will not do the play button I think. Can't be more detailed at the moment, because I'm on my phone. (will fix later with a more fuller description)

Upvotes: 1

Related Questions