How to make MPMoviePlayerController ignore the mute switch

zohar picture zohar · Dec 8, 2010 · Viewed 7.4k times · Source

I want to play a video using MPMoviePlayerController but I want it to ignore the mute switch, similar to the behavior of Youtube's video player.

Any ideas?

Answer

Carl Veazey picture Carl Veazey · Feb 8, 2011

Use the AVAudioSession category AVAudioSessionCategoryPlayback and your app will ignore the mute switch like the Youtube app.

For example (inspired by Ken Pletzer in the comments):

#import <AVFoundation/AVFoundation.h>

// note: you also need to add AVfoundation.framework to your project's 
// list of linked frameworks
NSError *error = nil;
BOOL success = [[AVAudioSession sharedInstance] 
                setCategory:AVAudioSessionCategoryPlayback 
                error:&error];
if (!success) {
    // Handle error here, as appropriate
}