I've created my own custom controls for use with the MPMoviePlayerController
. So far everything works except the mute button control.
I've configured the AVAudioSession
using the following code before I create my instance of the MPMoviePlayerController
.
NSError *modeError = nil;
[self.audioSession setMode:AVAudioSessionModeMoviePlayback error:&modeError];
if (modeError != nil) {
NSLog(@"Error setting mode for AVAudioSession: %@", modeError);
}
NSError *categoryError = nil;
[self.audioSession setCategory:AVAudioSessionCategoryPlayback error:&categoryError];
if (categoryError != nil) {
NSLog(@"Error setting category for AVAudioSession: %@", categoryError);
}
Then in my mute button callback method I have the following code:
NSError *activeError = nil;
[self.audioSession setActive:NO error:&activeError];
if (activeError != nil) {
NSLog(@"Error setting inactive state for AVAudioSession: %@", activeError);
}
When clicking the Mute button I get the following unuseful error:
Error Domain=NSOSStatusErrorDomain Code=560030580 "The operation couldn’t be completed. (OSStatus error 560030580.)"
I am linking to the AVFoundation
framework.
This is really starting to bug me as I can't for the life of me work out a way to reduce or mute the playback audio of my application.
I don't want to change the system global volume just the application level volume as defined by the AVAudioSession
AVAudioSessionCategoryPlayback
category.
It seems that you can set the volume of the AVAudioPlayer
but not the MPMoviePlayerController
. I've seen other posts here on SO that say just create an instance of AVAudioPlayer
and set the volume but this just causes my app to crash and I expect it has something to do with the fact I'm not using the initWithContentsOfURL:error:
or initWithData:error:
and instead using `init'.
Any help would be appreciated.