【问题标题】:Playing fullscreen video on iPhone without any user controls or interaction?在没有任何用户控制或交互的情况下在 iPhone 上播放全屏视频?
【发布时间】:2011-08-03 18:36:35
【问题描述】:

我正在开发一款带有介绍视频的 iOS 游戏。如何在没有以下情况的情况下全屏播放视频:

1) 播放/暂停等用户控件可见

2) 像双击或捏合这样的触摸来改变视频的比例/缩放?

要禁用对视频的点击,我可以在电影播放器​​视图上方添加一个空白 UIView 吗?我该怎么做?

【问题讨论】:

  • >>>要禁用对视频的点击,我可以在电影播放器​​视图上方添加一个空白 UIView 吗?我该怎么做?那可能行得通。尝试通过通知或仅原始委托方法重新关联事件处理程序,并覆盖这些方法以处理多点触控手势

标签: objective-c ios video uiview


【解决方案1】:

您使用的是什么类型的电影播放器​​? 如果您使用的是 MPMoviePlayerViewController/MPMoviePlayerController,您可以将 controlStyle 属性设置为 MPMovieControlStyleNone。 (如果您使用 MPMoviePlayerViewController,您首先调用 moviePlayer 属性,以便获得具有 controlStyle 属性的 MPMoviePlayerController)

例子:

MPMoviePlayerViewController* moviePlayerViewController = [MPMoviePlayerViewController alloc] initWithContentURL:url];
moviePlayerViewController.moviePlayer.controlStyle = MPMovieControlStyleNone;

【讨论】:

    【解决方案2】:

    我在 MPMoviePlayerController 上方添加了一个“空白”视图。我就是这样设置的。不必弄乱事件处理程序。

    mBlankView = [[UIView alloc] initWithFrame:viewFrame];
    mBlankView.userInteractionEnabled = YES;
    [mBlankView setMultipleTouchEnabled:YES];
    [mBlankView setBackgroundColor:[UIColor clearColor]];
    [window addSubview:mBlankView];    
    

    viewFrame 包含 MPMoviePlayerController 的大小。

    【讨论】:

      【解决方案3】:
      MPMoviePlayerViewController *playerViewController=[[MPMoviePlayerViewController alloc]initWithContentURL:[NSURL fileURLWithPath:[[NSBundle mainBundle]pathForResource:@"XYZ" ofType:@"mp4"]]];
      [self presentViewController:playerViewController animated:NO completion:nil];
      
      MPMoviePlayerController *player = [playerViewController moviePlayer];
      player.controlStyle=MPMovieControlStyleNone;   //hide the controls
      [player play];
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-10-08
        • 2011-10-27
        • 1970-01-01
        • 1970-01-01
        • 2013-01-27
        • 1970-01-01
        • 1970-01-01
        • 2013-07-28
        相关资源
        最近更新 更多