MPMoviePlayerController 与 UIModalPresentationPageSheet

发布于 2024-12-02 22:54:22 字数 1297 浏览 6 评论 0原文

我在 iPad 应用程序上的视图控制器上绘制了一个电影播放器​​。该视图使用 UIModalPresentationPageSheet 以模态方式显示。

视频显示正确,但全屏时,“完成”和“比例”按钮似乎没有任何作用。我如何启用这些按钮,以便在比例更改时退出全屏。

下面是我用来创建电影播放器​​的代码

NSString *url = [[NSBundle mainBundle] pathForResource:@"Movie" ofType:@"m4v"];
NSURL *strURL =[NSURL URLWithString:url];

player = [[MPMoviePlayerController alloc] initWithContentURL:strURL];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willEnterFullscreen:) name:MPMoviePlayerWillEnterFullscreenNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willExitFullscreen:) name:MPMoviePlayerDidExitFullscreenNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(enteredFullscreen:) name:MPMoviePlayerDidEnterFullscreenNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackFinished:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
[player setMovieSourceType:MPMovieSourceTypeFile];


//---play partial screen---
player.view.frame = CGRectMake(0, 42 , 780, 300);
[player prepareToPlay]; // this had to be in for it to work

[self.view addSubview:player.view];
player.shouldAutoplay = NO;

谢谢丹

i have a Movie player drawn onto my view controller on my iPad app. The view is shown modally using the UIModalPresentationPageSheet.

The video displays correctly but when full screen, the Done and ratio button seem to do nothing. How do i go about enable these buttons so that the full screen is exited when and ratio changed.

Below is my code that used to create the movie player

NSString *url = [[NSBundle mainBundle] pathForResource:@"Movie" ofType:@"m4v"];
NSURL *strURL =[NSURL URLWithString:url];

player = [[MPMoviePlayerController alloc] initWithContentURL:strURL];

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willEnterFullscreen:) name:MPMoviePlayerWillEnterFullscreenNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(willExitFullscreen:) name:MPMoviePlayerDidExitFullscreenNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(enteredFullscreen:) name:MPMoviePlayerDidEnterFullscreenNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playbackFinished:) name:MPMoviePlayerPlaybackDidFinishNotification object:nil];
[player setMovieSourceType:MPMovieSourceTypeFile];


//---play partial screen---
player.view.frame = CGRectMake(0, 42 , 780, 300);
[player prepareToPlay]; // this had to be in for it to work

[self.view addSubview:player.view];
player.shouldAutoplay = NO;

Thanks

Dan

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文