Skip to content

Instantly share code, notes, and snippets.

@liscio
Forked from anonymous/movieplayer
Created October 6, 2010 13:43
Show Gist options
  • Select an option

  • Save liscio/613357 to your computer and use it in GitHub Desktop.

Select an option

Save liscio/613357 to your computer and use it in GitHub Desktop.

Revisions

  1. Christopher Liscio revised this gist Oct 6, 2010. 1 changed file with 81 additions and 0 deletions.
    81 changes: 81 additions & 0 deletions movieplayer.m
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,81 @@
    //
    // videoTestMemoryViewController.h
    // videoTestMemory
    //
    // Created by david on 06/10/10.
    // Copyright 2010 E-ducation.it. All rights reserved.
    //

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

    @interface videoTestMemoryViewController : UIViewController {
    }

    - (IBAction)video;
    - (IBAction)dismissVideo;

    - (void)launchVideo;

    - (void)myMovieFinishedCallback:(NSNotification *) aNotification;
    - (void)myMovieExitFullscreenCallback:(NSNotification *) aNotification;
    - (void)myMovieLoadStateChangedCallback:(NSNotification *) aNotification;

    @end

    //
    // videoTestMemoryViewController.m
    // videoTestMemory
    //
    // Created by david on 06/10/10.
    // Copyright 2010 E-ducation.it. All rights reserved.
    //

    #import "videoTestMemoryViewController.h"

    @implementation videoTestMemoryViewController

    - (IBAction)video{
    [self launchVideo];
    }

    - (IBAction)dismissVideo {
    [self dismissModalViewControllerAnimated:YES];
    }

    - (void)launchVideo{
    NSString *path = [ [NSBundle mainBundle] pathForResource:@"010101" ofType:@"mp4" ];

    MPMoviePlayerViewController *mc = [ [MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:path] ];

    mc.moviePlayer.controlStyle = MPMovieControlStyleFullscreen;
    mc.moviePlayer.view.backgroundColor = [UIColor whiteColor];

    [mc.moviePlayer prepareToPlay];

    [self presentModalViewController:theMovieController animated:YES];
    [mc release];
    }

    - (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:YES];
    }

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;
    }

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

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


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

    @end
  2. @invalid-email-address Anonymous revised this gist Oct 6, 2010. 1 changed file with 101 additions and 0 deletions.
    101 changes: 101 additions & 0 deletions movieplayer
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,52 @@
    //
    // videoTestMemoryViewController.h
    // videoTestMemory
    //
    // Created by david on 06/10/10.
    // Copyright 2010 E-ducation.it. All rights reserved.
    //

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

    @interface videoTestMemoryViewController : UIViewController {

    MPMoviePlayerViewController *theMovieController;


    }


    - (IBAction)video;

    - (void)launchVideo;

    - (void)myMovieFinishedCallback:(NSNotification *) aNotification;
    - (void)myMovieExitFullscreenCallback:(NSNotification *) aNotification;
    - (void)myMovieLoadStateChangedCallback:(NSNotification *) aNotification;


    @end





    //
    // videoTestMemoryViewController.m
    // videoTestMemory
    //
    // Created by david on 06/10/10.
    // Copyright 2010 E-ducation.it. All rights reserved.
    //

    #import "videoTestMemoryViewController.h"



    @implementation videoTestMemoryViewController



    - (IBAction)video{

    @@ -54,3 +103,55 @@

    }


    /*
    // 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;
    }

    - (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 {
    NSLog(@"dealloc");


    [super dealloc];
    }

    @end
  3. @invalid-email-address Anonymous created this gist Oct 6, 2010.
    56 changes: 56 additions & 0 deletions movieplayer
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,56 @@

    - (IBAction)video{

    [self launchVideo];


    }



    - (void)launchVideo{

    NSString *path = [ [NSBundle mainBundle] pathForResource:@"010101" ofType:@"mp4" ];

    theMovieController = [ [MPMoviePlayerViewController alloc] initWithContentURL:[NSURL fileURLWithPath:path] ];

    theMovieController.moviePlayer.controlStyle = MPMovieControlStyleFullscreen;

    [theMovieController.moviePlayer prepareToPlay];

    [theMovieController.moviePlayer.view setBackgroundColor:[ UIColor whiteColor ]];


    [self presentModalViewController:theMovieController animated:YES];



    }






    - (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:YES];
    NSLog(@"viewWillAppear");

    if (theMovieController != nil) {

    NSLog(@"retainCount %d", [theMovieController retainCount]);

    [theMovieController release];

    NSLog(@"retainCount %d", [theMovieController retainCount]);

    theMovieController = nil;


    }




    }