Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You have several approaches available to you. Perhaps the simplest and most controllable is to subclass of <code>MPMoviePlayerViewController</code>.</p> <p>Start by having your <em>app</em> support ALL interface orientations (in the <code>app-info.plist</code>). Then restrict your <em>list view</em> (let's assume it's <code>MyListViewController.m</code>) to portrait with methods for both iOS 6 and earlier operating systems: </p> <pre><code>- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return UIInterfaceOrientationMaskPortrait; } - (NSUInteger) supportedInterfaceOrientations { return(UIInterfaceOrientationMaskPortrait); } - (BOOL) shouldAutorotate { return FALSE; } </code></pre> <p>Now create a new Objective C class derived from <code>MPMoviePlayerViewController</code>, called <code>MyMoviePlayerViewController</code>. Here's <code>MyMoviePlayerViewController.h</code>:</p> <pre><code>#import &lt;MediaPlayer/MediaPlayer.h&gt; @interface MyMoviePlayerViewController : MPMoviePlayerViewController @end </code></pre> <p>And here's <code>MyMoviePlayerViewController.m</code>:</p> <pre><code>#import "MyMoviePlayerViewController.h" @interface MyMoviePlayerViewController () @end @implementation MyMoviePlayerViewController - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation { return YES; } - (NSUInteger) supportedInterfaceOrientations { return(UIInterfaceOrientationMaskAll); } - (BOOL) shouldAutorotate { return TRUE; } -(id)initWithContentURL:(NSURL *)contentURL { UIGraphicsBeginImageContext(CGSizeMake(1,1)); self = [super initWithContentURL:contentURL]; UIGraphicsEndImageContext(); if (self) { self.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:[self moviePlayer]]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(movieFinishedCallback:) name:MPMoviePlayerPlaybackDidFinishNotification object:[self moviePlayer]]; } return self; } - (void)viewDidLoad { [super viewDidLoad]; [[self moviePlayer] setFullscreen:YES animated:NO]; [self moviePlayer].controlStyle = MPMovieControlStyleDefault; } - (void)movieFinishedCallback:(NSNotification*)notification { MPMoviePlayerController *moviePlayer = [notification object]; [[NSNotificationCenter defaultCenter] removeObserver:self name:MPMoviePlayerPlaybackDidFinishNotification object:moviePlayer]; self.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal; [self dismissViewControllerAnimated:YES completion:nil]; } @end </code></pre> <p>Then, add to <code>MyListViewController.h</code>:</p> <pre><code>#import "MyMoviePlayerViewController.h" </code></pre> <p>And, in <code>MyListViewController.m</code>, use:</p> <pre><code>MyMoviePlayerViewController *player =[[MyMoviePlayerViewController alloc] initWithContentURL:URLWithString:[[main_data objectAtIndex:indexPath.row] objectForKey:@"url"]]]; [self presentViewController:player animated:YES completion:nil]; </code></pre> <p>Obviously, you can tweak the settings (such as animation styles, controls to display...) to suite your specific needs.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload