Josh Kahane
Josh Kahane

Reputation: 17160

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.

Upvotes: 0

Views: 1372

Answers (1)

Dev Kanchen
Dev Kanchen

Reputation: 2352

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

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

Upvotes: 1

Related Questions