Search code examples
iphoneiosbuttonmedia-playerhide

Disable fullscreen mode in iOS Media Player Controller


I want to restrict the media player from entering into the fullscreen mode. Is it possible to customize the controllers of the iPhone media player controller? Can we disable the fullscreen button in the media player controller?


Solution

  • Check the fullscreen property and setFullscreen:animated methods as noted in the docs.

    Edit: I believe I misread your question--apologies.

    Not the best solution, but you could override setFullscreen: to simply ignore the request:

     - (void)setFullscreen:(BOOL)full {
          // Ignore request      
     }
    

    As far as customizing the controls, you have the option of setting the controlStyle, but all of these have a full screen button, save the "MPMovieControlStyleNone", which give you no controls. You could combine the MPMovieControlStyleNone and overlay your own control bar.

    I would probably go for the latter myself, as a disabled button I expect to work as a user would probably be frustrating.

    Hope that at least partially earns-away that down vote. :-)

    Edit: Adding some more info/code

    So here's just something simple you could do. I build a toolbar using IB

    toolbar.tiff

    and a bit of code for placement and some silly color (this one's a little harsh actually):

    NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"bar" owner:self options:nil];
    UIToolbar *toolbar;
    if ( nil != array ) {
        toolbar = array[0];
    }
    
    CGSize barSize = CGSizeMake(self.window.frame.size.width, 44);
    CGSize winSize = self.window.frame.size;
    
    [toolbar setFrame:CGRectMake(0, winSize.height - barSize.height, winSize.width, barSize.height)];
    [toolbar setTranslucent:YES];
    [toolbar setBackgroundImage:nil forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault];
    [toolbar setTintColor:[UIColor colorWithRed:138/255 green:187/255 blue:255/227 alpha:0.4]];
    
    [self.window addSubview:toolbar];
    

    Just connect up the buttons, maybe do a clear-color overlay to handle the tap-to-bring-up-controls functionality that's already common in the movie players.