title: Looping a video with AVFoundation AVPlayer?
body: <p>Is there a relatively easy way of looping a video in AVFoundation?  </p>
  
  <p>I've created my AVPlayer and AVPlayerLayer like so:</p>
  
  <pre><code>avPlayer = [[AVPlayer playerWithURL:videoUrl] retain];
  avPlayerLayer = [[AVPlayerLayer playerLayerWithPlayer:avPlayer] retain];
  
  avPlayerLayer.frame = contentView.layer.bounds;
  [contentView.layer addSublayer: avPlayerLayer];
  </code></pre>
  
  <p>and then I play my video with:</p>
  
  <pre><code>[avPlayer play];
  </code></pre>
  
  <p>The video plays fine but stops at the end.  With the MPMoviePlayerController all you have to do is set its <code>repeatMode</code> property to the right value.  There doesn't appear to be a similar property on AVPlayer.  There also doesn't seem to be a callback that will tell me when the movie has finished so I can seek to the beginning and play it again.</p>
  
  <p>I'm not using MPMoviePlayerController because it has some serious limitations.  I want to be able to play back multiple video streams at once.</p>