title: Playing video from within app?
body: <p>I am trying to play a local video from my app using AVPlayer. I have looked everywhere but can't find any useful tutorials/demos/documentation. Here is what I am trying, but it is not playing. Any idea why? The URL is valid because I was using the same one to play a video using MPMoviePlayer successfully.</p>
  
  <pre><code>       Video *currentVideo = [videoArray objectAtIndex:0];
  
      NSString *filepath = currentVideo.videoURL;
      NSURL *fileURL = [NSURL fileURLWithPath:filepath];
  
      AVURLAsset *asset = [AVURLAsset assetWithURL: fileURL];
      AVPlayerItem *item = [AVPlayerItem playerItemWithAsset: asset];
      self.player = [[AVPlayer alloc] initWithPlayerItem: item];
  
  
      AVPlayerLayer *layer = [AVPlayerLayer playerLayerWithPlayer:self.player];
      self.player.actionAtItemEnd = AVPlayerActionAtItemEndNone;
  
  
      layer.frame = CGRectMake(0, 0, 1024, 768);
      [self.view.layer addSublayer: layer];
  
  
      [self.player play];
  </code></pre>