Play a movie in fullscreen (Objective-C)

Hi,

In reply to http://snipd.net/objective-c-play-a-video-in-full-screen#comment-290 . The following snippets show how to play a movie in fullscreen.

PlayerView.h

//
//  PlayerView.h
//
//  Created by Ferhat Yildiz
//

#import <Foundation/Foundation.h>
#import <MediaPlayer/MediaPlayer.h>

@interface PlayerView : MPMoviePlayerViewController {

}

@end

PlayerView.m

//
//  PlayerView.m
//
//  Created by Ferhat Yildiz
//

#import "PlayerView.h"

@implementation PlayerView
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
    return YES;
}

@end

MoviePlayer.m

			NSURL *url = [NSURL URLWithString:<video url>];  

			PlayerView * playerView;
			playerView = [[PlayerView alloc] initWithContentURL: url];

			MPMoviePlayerController * moviePlayerController = [playerView moviePlayer];
			moviePlayerController.scalingMode = MPMovieScalingModeAspectFit;
			moviePlayerController.fullscreen = YES;
			moviePlayerController.controlStyle = MPMovieControlStyleFullscreen;
			moviePlayerController.shouldAutoplay = YES;
			[self presentMoviePlayerViewControllerAnimated:playerView];

- Ferhat

This entry was posted in Objective-C and tagged , , , , , , , . Bookmark the permalink. Trackbacks are closed, but you can post a comment.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Why ask?