我正在使用 MPMoviePlayer 在我的应用程序中播放本地视频文件。文件为 .mov 格式。当我在模拟器中运行我的应用程序时,它工作正常。但是当我在 iPhone 中运行它时,视频运行时没有声音。这是我的代码,
self.currUrl = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"Gun_Shot" ofType:@"mov"]];
if (self.mpc)
{
[self.mpc release];
self.mpc = nil;
}
self.mpc = [[MPMoviePlayerController alloc]
initWithContentURL:self.currUrl];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidFinish:) name:MPMoviePlayerPlaybackDidFinishNotification object:self.mpc];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackLoadStateDidChange:) name:MPMoviePlayerLoadStateDidChangeNotification object:self.mpc];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidEnterFullScreen:) name:MPMoviePlayerDidEnterFullscreenNotification object:self.mpc];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackDidExitFullScreen:) name:MPMoviePlayerDidExitFullscreenNotification object:self.mpc];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackNowPlayingContinues:) name:MPMoviePlayerNowPlayingMovieDidChangeNotification object:self.mpc];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(moviePlayBackStateChanged:) name:MPMoviePlayerPlaybackStateDidChangeNotification object:self.mpc];
self.mpc.controlStyle = MPMovieControlStyleNone;
self.mpc.shouldAutoplay = NO;
self.mpc.view.frame = CGRectMake(0, 0, self.mpView.frame.size.width, self.mpView.frame.size.height);
[self.mpView addSubview:self.mpc.view];
[self.mpView bringSubviewToFront:self.topMainView];
[self.mpView bringSubviewToFront:self.bottomMainView];
[self.mpc prepareToPlay];
self.timeLbl.text = [NSString stringWithFormat:@"%f Sec(s)", self.mpc.duration];
我不明白为什么当应用程序在 iPhone 上运行时视频会静音。任何帮助将不胜感激..