Search code examples
iphoneobjective-caudiomute

iPhone SDK - Mute


I have the following to play m background music:

NSURL *url = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/bgMusic.mp3", [[NSBundle mainBundle] resourcePath]]];

    NSError *error;
    bgMusic = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:&error];
    bgMusic.numberOfLoops = -1;
    bgMusic.volume = 0.1;

    if (bgMusic == nil)
        NSLog([error description]);
    else
        [bgMusic play];

But how I can I in any view, mute all sounds, not just this, any sound?

Thanks.


Solution

  • [[MPMusicPlayerController applicationMusicPlayer] setVolume:(use a value between 0.0 and 1.0)]

    If your MPMoviePlayerController uses the application audio session, this works.