我有一个奇怪的问题给你们。
MPMoviePlayerController正在播放视频,音频只能通过耳机播放。
真正的拖累是这只发生在某些iPad 和 iPhone 上,即使是运行相同系统的相同模型!
我在这里创建了一个简单的失败示例:
http://www.porcaro.org/MPMoviePlayerController/TestMovie.zip
我已经看到它在 iPhone 4S、iPhone 4 和 iPad 2 上运行良好但失败了。
这是最相关的代码。感谢您的任何见解,我也将向 Apple 提交一个错误:
(void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
moviePath = [NSString stringWithFormat:@"%@/intro.m4v", [[NSBundle mainBundle] bundlePath]];
NSURL *movieURL = [NSURL fileURLWithPath:moviePath];
theMoviePlayer = [[MPMoviePlayerController alloc] initWithContentURL:movieURL];
controlStyle = MPMovieControlStyleEmbedded;
movieView = [self view];
movieRect = [[self view] frame];
controlStyle = MPMovieControlStyleFullscreen;
theMoviePlayer.controlStyle = controlStyle;
theMoviePlayer.view.userInteractionEnabled = YES;
if (1) {
NSLog(@"Created theMoviePlayer: %@. Playing: %@", theMoviePlayer, moviePath);
}
[[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackStateDidChangeNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(checkForEndOfMovie:)
name:MPMoviePlayerPlaybackStateDidChangeNotification
object:theMoviePlayer];
// this line doesn't fix the problem
//[theMoviePlayer prepareToPlay];
[[theMoviePlayer view] setFrame:movieRect];
[movieView addSubview: [theMoviePlayer view]];
[theMoviePlayer play];
}