Reputation: 111
I am new to Xcode,please help me out. I added AVPlayer in View Controller in IOS app.It displays Video in view But without audio. Any help anybody Advance thank you
Upvotes: 2
Views: 546
Reputation: 579
the reason you audio is mute because you might have not initialize AVAudioSession Check this out ..
AVAudioSession *session = [AVAudioSession sharedInstance];
[session setCategory:AVAudioSessionCategoryPlayback error:nil];
UIView *myView = previewView;
videoController = [[MPMoviePlayerViewController alloc]initWithContentURL:videoPlayUrl];
videoController.view.frame = myView.bounds;
[videoController.view setBounds:previewView.bounds];
videoController.moviePlayer.controlStyle = MPMovieControlStyleNone;
videoController.moviePlayer.scalingMode = MPMovieScalingModeFill;
videoController.moviePlayer.shouldAutoplay = NO;
videoController.view.clipsToBounds = YES;
[previewView.layer addSublayer:videoController.view.layer];
[videoController.moviePlayer prepareToPlay];
Upvotes: 3