我有一个流式传输视频的MPMoviePlayerController。问题是视频和音频在模拟器中工作正常,但在设备上,视图只是变黑,没有音频或视频出现。这是我的代码:
- (IBAction)playVideoPress:(id)sender
{
MPMoviePlayerController *player = [[MPMoviePlayerController alloc] initWithContentURL:mediaURL];
_mpPlayer3 = player;
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(moviePlayerDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:nil];
_mpPlayer3.controlStyle = MPMovieControlStyleDefault;
[_playerView3 addSubview: _mpPlayer3.view];
[_mpPlayer3.view setFrame:_playerView3.bounds];
[_mpPlayer3 play];
}
然后视频结束时的通知是:
- (void)moviePlayerDidFinish:(NSNotification*)notification {
[[NSNotificationCenter defaultCenter]
removeObserver:self
name:MPMoviePlayerPlaybackDidFinishNotification
object:nil];
NSLog(@"Did Finish Notification");
[_mpPlayer3 stop];
_mpPlayer3 = nil;
}
这在模拟器中运行良好,但只是在视图中显示我要显示视频的黑屏。发生的另一个奇怪的事情是,当我在模拟器中运行它时,我得到一堆错误,如为:
Error loading /System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn: dlopen(/System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn, 262): Symbol not found: ___CFObjCIsCollectable
我不知道这与播放视频的模拟器和设备有什么关系,但我想我会在这里提一下。