Is it possible to mute MPMoviePlayerController?

2019-03-16 18:21发布

问题:

In my iPhone application I want to mute & unmute MPMoviePlayerController. I have searched a lot but I am unable to succeed. Is it possible to mute audio in MPMoviePlayer controller? Please help me out. Thanks in advance.

回答1:

[[MPMusicPlayerController applicationMusicPlayer] setVolume:0];

This Line will mute the sound(hopefully)..:)



回答2:

Use this to mute.

NSError *error;
if ( ![[AVAudioSession sharedInstance] setActive:NO error:&error] ) {
    NSLog(@"Error encountered: %@", [error localizedDescription]);
}

You will have to include the AVFoundation framework.