0

我是implementeinbg MPMoviePlayerController,我正在使用这个方法(presentMoviePlayerViewControllerAnimated)来呈现我

moviePlayerController = [[MPMoviePlayerController alloc] initWithContentURL:fileURL];
[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(moviePlaybackComplete:)
                                             name:MPMoviePlayerPlaybackDidFinishNotification
                                           object:moviePlayerController];

[moviePlayerController.view setFrame:CGRectMake(0, 0, 320, 480)];

moviePlayerController.controlStyle = MPMovieControlStyleFullscreen;
moviePlayerController.view.userInteractionEnabled =YES;


[self presentMoviePlayerViewControllerAnimated:moviePlayerController];

但是当我展示我传递所需的参数时,我收到警告不兼容类型。

4

2 回答 2

1

您正在尝试呈现MPMoviePlayerController而不是MPMoviePlayerViewController这就是警告的原因。

还要记住,没有controlStyle属性MPMoviePlayerViewController

所以像这样使用:

- (void)showMedia
{
   MPMoviePlayerViewController *moviePlayerView = [[MPMoviePlayerViewController alloc] initWithContentURL:fileURL];
   [[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(moviePlaybackComplete:)
                                             name:MPMoviePlayerPlaybackDidFinishNotification
                                           object:moviePlayerView.moviePlayer];

   [moviePlayerView.view setFrame:CGRectMake(0, 0, 320, 480)];
   moviePlayerView.view.userInteractionEnabled =YES;
   [self presentMoviePlayerViewControllerAnimated:moviePlayerView];
}
于 2013-06-17T09:33:49.287 回答
0

您提供的不是视图控制器,而是 MPMoviePlayerController。那是一个不同的对象。如果您想在视图控制器中显示电影播放器​​控制器,请尝试使用 MPMoviePlayerViewController。

于 2013-06-17T09:26:33.353 回答