更新时间:2023-09-22 09:45:16
与其创建一个 MPMoviePlayerController
并将其添加到您的视图中,不如创建一个 MPMoviePlayerViewController
可能更简单> 并以模态方式呈现该视图控制器(因为您无论如何都试图全屏显示视频).然后 MPMoviePlayerViewController 可以为您管理视频的呈现.
Instead of creating a MPMoviePlayerController
and adding that to your view, it is probably simpler to create a MPMoviePlayerViewController
and present that view controller modally (since you are trying to show your video full screen anyway). Then the MPMoviePlayerViewController can manage the presentation of your video for you.
MPMoviePlayerViewController *mpvc = [[MPMoviePlayerViewController alloc] initWithContentURL:url];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(moviePlaybackDidFinish:)
name:MPMoviePlayerPlaybackDidFinishNotification
object:nil];
mpvc.moviePlayer.movieSourceType = MPMovieSourceTypeStreaming;
[self presentMoviePlayerViewControllerAnimated:mpvc];
[mpvc release];
在您的 moviePlayBackDidFinish
委托方法中,您可以关闭模型视图控制器.
In your moviePlayBackDidFinish
delegate method you can then dismiss the model view controller.