我的应用程序捕获视频。我已经检查过该视频文件有声音,但在应用程序中它没有播放MPMoviePlayerController。我注意到,对于短视频,不到5秒钟,声音正在播放。
-(void) showMovie:(NSString*)moviePath{
[self initializeMoviePlayer:moviePath];
[self setMoviePath:moviePath];
[movieController play];
}
-(void) initializeMoviePlayer:(NSString*)moviePath{
if (movieController == nil) {
movieController = [[MPMoviePlayerController alloc] initWithContentURL:[[NSURL alloc] initFileURLWithPath:moviePath]];
movieController.repeatMode = MPMovieRepeatModeOne;
[movieController prepareToPlay];
[movieController setUseApplicationAudioSession:NO];
[movieController setShouldAutoplay:YES];
[movieController setControlStyle:2];
movieController.fullscreen = YES;
movieController.scalingMode =MPMovieScalingModeAspectFill;
movieController.controlStyle = MPMovieControlStyleNone;
movieController.view.autoresizingMask = UIViewAutoresizingFlexibleHeight |UIViewAutoresizingFlexibleWidth;
[movieController.view setFrame: self.frame];
[self insertSubview:self.movieController.view atIndex:0];
}
}