ios - MPMediaPlayerController 永久隐藏用户界面元素

标签 ios iphone ipad user-interface mpmediaplayercontroller

我使用 MPMediaPlayerController,我需要永久隐藏 UI 元素。 但是当播放器开始播放视频时我可以看到它,2 秒后它隐藏了。 我使用:

setControlStyle:MPMovieControlModeHidden

MPMediaPlayerController

player = [[MPMoviePlayerController alloc] initWithContentURL:[NSURL URLWithString:@"http://catholictvhd-lh.akamaihd.net/i/ctvhd_1@88148/index_3_av-p.m3u8"]];


[player.view setFrame:self.view.bounds];
player.view.backgroundColor = [UIColor blueColor];
player.view.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
CGSize maxSize;



if([[UIScreen screens]count] > 1) {
    [self logIt:@"External screen is available"];
    newwindow = [[UIWindow alloc] init];
    // There is a external display.
    UIScreenMode *maxScreenMode;
    for(int i = 0; i < [[[[UIScreen screens] objectAtIndex:1] availableModes]count]; i++)
    {
        UIScreenMode *current = [[[[UIScreen screens]objectAtIndex:1]availableModes]objectAtIndex:i];
        if(current.size.width > maxSize.width)
        {
            maxSize = current.size;
            maxScreenMode = current;
        }
    }
    UIScreen *external = [[UIScreen screens] objectAtIndex:1];
    external.currentMode = maxScreenMode;

    [self logIt:[NSString stringWithFormat:@"%@",maxScreenMode]];
    newwindow.screen = external;
    // setting external display size.
    CGPoint point = CGPointMake(0.0f, 0.0f);
    //CGSize size = CGSizeMake(1024.0f, 768.0f);
    CGSize size = maxSize;
    CGRect frame = player.view.frame;
    frame.origin = point;
    frame.size.width = size.width;
    frame.size.height = size.height;
    [player.view setFrame:frame];
    [player setControlStyle:MPMovieControlModeHidden];

    [player setFullscreen:YES animated:YES];

    player.shouldAutoplay = YES;


    [player prepareToPlay];
    [player play];

最佳答案

player.moviePlayer.controlStyle = MPMovieControlStyleNone;  // to hide controls

在播放视频之前,您必须将 subview 添加为 MPMoviePlayerController

播放前加入这一行

[self.view addSubview:player.view];

关于ios - MPMediaPlayerController 永久隐藏用户界面元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20788174/

相关文章:

ios - 如何在使用 drawrect() 绘制后删除标签

ios - 透明的 iOS 导航栏

iphone - 如何将 -mthumb 添加到 Xcode

ios - UILabel 文本未出现在某些 iOS 设备上

ios - 为什么我不能安装三个以上的应用程序?

iphone - 使用 switch 语句读取 NSDictionary

ios - 将 AIR Native Extension 与 FLA 项目集成

ios - 是否可以在 iOS 上禁用 WiFi 和 3G

iphone - 如何使用 iPhone 应用程序在 MVC4 apicontroller 中提供用户安全

iphone - 关于运送 iphone 应用程序的安全问题