IPhone : How to mute audio using MPMoviePlayerController?

on Thursday, March 26, 2015

MPMoviePlayerController * _moviePlayerController = [[MPMoviePlayerController alloc] init]; _moviePlayerController.controlStyle = MPMovieControlStyleDefault;



NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"test" ofType:@"mp4"]];
_moviePlayerController.contentURL = url;
_moviePlayerController.fullscreen=NO;

_moviePlayerController.backgroundView.backgroundColor = [UIColor whiteColor];
for(UIView *aSubView in _moviePlayerController.view.subviews) {
aSubView.backgroundColor = [UIColor whiteColor];
}
// Rotating the player to landscape position
_moviePlayerController.view.frame = CGRectMake(0.0f,
0.0f,
[UIScreen mainScreen].bounds.size.width,
[UIScreen mainScreen].bounds.size.height);


// _moviePlayerController.view.transform = CGAffineTransformMakeRotation(M_PI_2); _moviePlayerController.view.center = self.view.center;



UIView *playerView = _moviePlayerController.view;
playerView.frame = CGRectMake(0.0f,
0.0f,
[UIScreen mainScreen].bounds.size.width,
[UIScreen mainScreen].bounds.size.height);


[videoPlayerView addSubview:playerView];
_moviePlayerController.shouldAutoplay=NO;
[_moviePlayerController prepareToPlay];
[_moviePlayerController pause];

0 comments:

Post a Comment