title: AVPlayer on ios Objective C app does not play video
body: <p>Hi I have an iOS Objective-C app which does not use Storyboards (It uses XIB files)</p>
  
  <p>I want to add a splash screen to play a video so I added a new Coca Touch Class derived from UIViewController (And ticked 'Also create XIB file).</p>
  
  <p>I have swapped this class as my new main screen and it loads properly but does not play the video.  I have added the AVFoundation framework etc so that is not an issue.</p>
  
  <p>Here is my code.</p>
  
  <p><strong>.h File</strong></p>
  
  <pre><code>#import &lt;UIKit/UIKit.h&gt;
  
  @interface VideoIntroViewController : UIViewController
  @property (strong, nonatomic) NSManagedObjectContext *managedObjectContext;
  @end
  </code></pre>
  
  <p><strong>.m file</strong></p>
  
  <pre><code>import &lt;AVFoundation/AVFoundation.h&gt;
  
  static const float PLAYER_VOLUME = 0.0;
  
  @interface VideoIntroViewController ()
  
  @property (nonatomic) AVPlayer *player;
  @property (weak, nonatomic) IBOutlet UIView *playerView;
  
  @end
  
  @implementation VideoIntroViewController
  
  - (void)viewDidLoad
  {
      [super viewDidLoad];
      [self createVideoPlayer];
  }
  
  - (void)createVideoPlayer
   {
      NSString *filePath = [[NSBundle mainBundle] pathForResource:@"welcome_video" ofType:@"mp4"];
      NSURL *url = [NSURL fileURLWithPath:filePath];
  
      AVPlayerItem *playerItem = [AVPlayerItem playerItemWithURL:url];
  
      self.player = [AVPlayer playerWithPlayerItem:playerItem];
      self.player.volume = PLAYER_VOLUME;
  
      AVPlayerLayer *playerLayer = [AVPlayerLayer playerLayerWithPlayer:self.player];
      playerLayer.videoGravity = UIViewContentModeScaleToFill;
      playerLayer.frame = self.playerView.layer.bounds;
      [self.playerView.layer addSublayer:playerLayer];
  
      [self.player play];
  }
  </code></pre>
  
  <p>The screen launched but no video plays.</p>
  
  <p>What could be going wrong?</p>