MPMoviePlayerController仅在通用应用程序中引发错误

我的应用程序在应用程序启动时以全屏模式播放视频。一切都从3.0到4.1完美无缺地工作。MPMoviePlayerController仅在通用应用程序中引发错误

但是,如果我为通用应用编译相同的代码,它将在iPad上工作,但不再适用于iPhone(模拟器)。

有没有人解决过这个问题?

下面的代码:

if ([self respondsToSelector:@selector(presentMoviePlayerViewControllerAnimated:)]) { 

videoPath = [[NSBundle mainBundle] pathForResource:@"portrait" ofType:@"mov"];

videoURL = [NSURL fileURLWithPath:videoPath];

MPMoviePlayerController *aMoviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];

self.moviePlayerController = aMoviePlayerController;

[aMoviePlayerController release];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(startVideo:) name:MPMoviePlayerLoadStateDidChangeNotification object:nil];

[moviePlayerController.view setFrame:self.view.bounds];

[self.view addSubview:moviePlayerController.view];

moviePlayerController.controlStyle = MPMovieControlStyleNone;

} else {

//OS < 3.2

videoPath = [[NSBundle mainBundle] pathForResource:@"landscape" ofType:@"mov"];

videoURL = [NSURL fileURLWithPath:videoPath];

MPMoviePlayerController *aMoviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];

self.moviePlayerController = aMoviePlayerController;

[aMoviePlayerController release];

moviePlayerController.movieControlMode = MPMovieControlModeHidden;

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(startVideo:) name:MPMoviePlayerContentPreloadDidFinishNotification object:nil];

}

而这里的错误:

-[MPMoviePlayerControllerOld view]: unrecognized selector sent to instance

0x7924470

即使我试图阻止这个是这样的...

if ([moviePlayerController respondsToSelector:@selector(view)]) { 

[moviePlayerController.view setFrame:self.view.bounds];

}

...的错误仍然被抛出。

回答:

我得到了同样的错误几天前。它只需要将基础sdk从3.2更改为4.1 希望它有帮助

回答:

我没有解释错误,但。但是,这似乎工作(需要测试的旧设备):

if ([self respondsToSelector:@selector(presentMoviePlayerViewControllerAnimated:)]) { 

videoPath = [[NSBundle mainBundle] pathForResource:@"portrait" ofType:@"mov"];

videoURL = [NSURL fileURLWithPath:videoPath];

/* NEW */

MPMoviePlayerViewController *aMoviePlayerViewController = [[MPMoviePlayerViewController alloc] initWithContentURL:videoURL];

aMoviePlayerViewController.moviePlayer.view.frame = self.view.bounds;

aMoviePlayerViewController.moviePlayer.controlStyle = MPMovieControlStyleNone;

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(startVideo:) name:MPMoviePlayerLoadStateDidChangeNotification object:nil];

[aMoviePlayerViewController.moviePlayer play];

[self.view addSubview:aMoviePlayerViewController.view];

self.moviePlayerController = aMoviePlayerViewController;

} else {

//OS < 3.2

videoPath = [[NSBundle mainBundle] pathForResource:@"landscape" ofType:@"mov"];

videoURL = [NSURL fileURLWithPath:videoPath];

MPMoviePlayerController *aMoviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:videoURL];

self.moviePlayerController = aMoviePlayerController;

aMoviePlayerController.movieControlMode = MPMovieControlModeHidden;

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(startVideo:) name:MPMoviePlayerContentPreloadDidFinishNotification object:nil];

[aMoviePlayerController release];

}

如果我能记得我为什么这样做是摆在首位的其他方式;)

以上是 MPMoviePlayerController仅在通用应用程序中引发错误 的全部内容, 来源链接: utcz.com/qa/261271.html

回到顶部