How to hide the MPMoviePlayer video controls?

advertisements

I have managed to make my app play a video, but I am a beginner and I don't know how to code that well, I can't figure out how to hide the video controls. I couldn't find out how to from the Internet, since my code is different from others and I don't know where to put single pieces of code in my code. This is my code:

//
//  PlayVideoViewController.m
//  PlayVideo
//
//  Created by Barry on 5/18/11.
//  Copyright __MyCompanyName__ 2011. All rights reserved.
//

#import "PlayVideoViewController.h"
#import <MediaPlayer/MediaPlayer.h>

@implementation PlayVideoViewController

- (void)viewDidLoad {

    NSString *url = [[NSBundle mainBundle]
                                         pathForResource:@"Charlie"
                                         ofType:@"mp4"];

    MPMoviePlayerController *player =
        [[MPMoviePlayerController alloc]
         initWithContentURL:[NSURL fileURLWithPath:url]];

    [[NSNotificationCenter defaultCenter]
         addObserver:self
         selector:@selector(movieFinishedCallback:)
         name:MPMoviePlayerPlaybackDidFinishNotification
         object:player];

    //---play movie---
    [player play];
    [super viewDidLoad];
}

- (void) movieFinishedCallback:(NSNotification*) aNotification {
    MPMoviePlayerController *player = [aNotification object];
    [[NSNotificationCenter defaultCenter]
         removeObserver:self
         name:MPMoviePlayerPlaybackDidFinishNotification
         object:player];
    [player autorelease];
}

/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        // Custom initialization
    }
    return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/

/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/

/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
        // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

        // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
        // Release any retained subviews of the main view.
        // e.g. self.myOutlet = nil;
}

- (void)dealloc {
    [super dealloc];
}

@end

How can I change this to disable the video controls?


Define the controlStyle property on the MPMoviePlayerController object.

Constants describing the style of the playback controls.

enum {
   MPMovieControlStyleNone,
   MPMovieControlStyleEmbedded,
   MPMovieControlStyleFullscreen,
   MPMovieControlStyleDefault = MPMovieControlStyleFullscreen
};
typedef NSInteger MPMovieControlStyle;

In your case you would write player.controlStyle = MPMovieControlStyleNone

Read more from here