iPad MPMoviePlayerController - 禁用全屏

Mat*_*euF 14 fullscreen mpmovieplayercontroller ipad ios

有没有办法禁用MPMoviePlayerController的全屏按钮?

bor*_*kur 11

刚刚做到了:

- (void)viewDidLoad {
    [super viewDidLoad];

    [[NSNotificationCenter defaultCenter] addObserver:self 
                                             selector:@selector(movieEventFullscreenHandler:) 
                                                 name:MPMoviePlayerWillEnterFullscreenNotification 
                                               object:nil];

    [[NSNotificationCenter defaultCenter] addObserver:self 
                                             selector:@selector(movieEventFullscreenHandler:) 
                                                 name:MPMoviePlayerDidEnterFullscreenNotification 
                                               object:nil];

    self.moviePlayer.controlStyle = MPMovieControlStyleEmbedded;
}

- (void)movieEventFullscreenHandler:(NSNotification*)notification {
    [self.moviePlayer setFullscreen:NO animated:NO];
    [self.moviePlayer setControlStyle:MPMovieControlStyleEmbedded];
}
Run Code Online (Sandbox Code Playgroud)

  • 不错的主意,我想我可以使用它来触发警报来解释为什么在当前上下文中不允许全屏并强制它保持嵌入模式.不幸的是,实际发生的事情是你仍然可以转换到全屏,然后它又回到嵌入式看起来非常可怕. (4认同)

Phi*_*hil 7

根据您的需要,您还可以简单地禁用播放器视图上的所有用户交互.

player.view.userInteractionEnabled = NO;
Run Code Online (Sandbox Code Playgroud)


dOM*_*dOM 6

您可以将controlStyle设置为Fullscreen.这些控件有些不同,但它没有全屏按钮!

[_moviePlayerController setControlStyle:MPMovieControlStyleFullscreen];
Run Code Online (Sandbox Code Playgroud)


Ant*_*ain 5

您可以隐藏播放控件并添加自己的自定义控件,这样可以防止默认按钮被渲染

[player setMovieControlMode:MPMovieControlModeNone];
Run Code Online (Sandbox Code Playgroud)


Jav*_*ría 5

不幸的是,上面没有一个对我有用,所以选择上面我实现了以下(并且工作正常):

  1. 隐藏全屏按钮.

在初始化电影播放器​​的方法中添加此代码.


    ....

        //Because we have to wait until controllers are shown

        [self performSelector:@selector(hideFullscreenButton) withObject:self afterDelay:0.5];

    ...

添加方法:


    -(void) hideFullscreenButton{

        //Hide full screen mode button

        [self hideFullscreenSubview:movieClip.view.subviews];

    }



    -(void) hideFullscreenSubview:(NSArray*)arr{

        for(UIView *v in arr){

            if([v.subviews count]>0)

                [self hideFullscreenSubview:v.subviews];

            else

                NSLog(@"%@",v);

            if(v.frame.origin.x==975 ){

                v.hidden=TRUE;

            }

        }

    }

问题依赖于没有标记来标识您必须隐藏哪个视图.在我的情况下,我通过视图坐标计算出来.

  1. 覆盖轻击手势,不允许全屏缩放.

 movieClip.controlStyle = MPMovieControlStyleEmbedded;    

    //Disable tap for not allowing that video control set on a full screen mode.
    UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget: self action:@selector(doSingleTap)];
    singleTap.numberOfTapsRequired = 1;
    [movieClip.view addGestureRecognizer:singleTap];



    UITapGestureRecognizer *doubleTap = [[UITapGestureRecognizer alloc] initWithTarget: self action:@selector(doDoubleTap)];
    doubleTap.numberOfTapsRequired = 2;
    [movieClip.view addGestureRecognizer:doubleTap];
    [singleTap requireGestureRecognizerToFail:doubleTap];

并添加选择器方法:


    -(void) doSingleTap{
        //DO NOTHING!!!
    }

    -(void) doDoubleTap{
        //DO NOTHING!!!
    }


Ret*_*ogs 3

不,没有办法。希望下次更新。