Rich Brooks
Rich Brooks

Reputation: 521

MPMoviePlayerController is not responding to device volume controls

I'm working on a game that during the title sequence plays a video in the background using MPMoviePlayerController. I overlay my game controls over this (just a few textured UIButtons).

The video itself has no audio, but I'm playing sounds when I press buttons via OpenAL. The Audio Session is set to "Ambient" and whenever the MPMoviePlayerController is not around it responds correctly to device's mute button and volume. But as soon as the video starts playing it blares out the sounds with no regard to the mute or volume settings.

Can anyone help me? Is the MPMoviePlayerController interfering with the AudioSession state? Is there a way to stop this from happening. My movie has no sound in it so it shouldn't need to do that.

Upvotes: 2

Views: 1666

Answers (1)

Matt Hudson
Matt Hudson

Reputation: 7348

The MPMoviePlayerController uses the AVAudioPlayer shared instance. So you can literally set the volume of the MPMoviePlayerController and it will turn down your background music. However, a better way is to tell MPMoviePlayerController to not use the shared instance.

NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"intro" ofType:@"m4v"]];
self.player = [[MPMoviePlayerController alloc] initWithContentURL:url];
self.player.movieSourceType = MPMovieSourceTypeFile;
**[self.player setUseApplicationAudioSession:FALSE];**

Upvotes: 2

Related Questions