title: Playing and Downloading an MP3 file using AVPlayer
body: <p>I'm currently using the following code to play a mp3 with AVPlayer</p>
  
  <pre><code>    NSString *title = [[NSString alloc] initWithFormat:@"http://.......com/%@", mp3File];
      NSURL *url = [[NSURL alloc] initWithString:title];
      AVPlayerItem *anItem = [AVPlayerItem playerItemWithURL:url];
  
  
      player = [AVPlayer playerWithPlayerItem:anItem];
  
      [player play];
  </code></pre>
  
  <p>However I also want to store the downloaded file, so subsequent plays will not require downloading the file again. For this I am using the following</p>
  
  <pre><code>     NSString  *path = [NSHomeDirectory() stringByAppendingPathComponent:[@"Documents/" stringByAppendingString:surahAyah]];
  
       if (![[NSFileManager defaultManager] fileExistsAtPath:path])
       {
          NSString *title = [[NSString alloc] initWithFormat:@"http://.......com/%@", mp3File];
          NSURL *url = [[NSURL alloc] initWithString:title];
  
          NSData *dbFile = [[NSData alloc] initWithContentsOfURL:url];
          [dbFile writeToFile:path atomically:YES];
       }
  </code></pre>
  
  <p>What is the best practice for consolidating the above and making using of the cached? AVPlayerItem and storing that instead of making a fresh call to download and save the file?</p>
  
  <p>The MP3 files are approximately 100KB in size, so I'm not too worried about download progress.</p>