title: AVPlayer selectively playing MP3 audio file in documents directory
body: <p>I'm writing a podcast app and I want the user to play the local file they've downloaded if it exists (rather than stream it). The streaming works fine, but if the local file is found, it's not played by AVPlayer (this is actually not true for one out of about 5 files for reasons beyond me -- tapping on one podcast will play locally (I'm in airplane mode to verify). </p>
  
  <p>I believe this is the Swift equivalent of <a href="https://stackoverflow.com/questions/12155055/avplayer-not-playing-mp3-audio-file-in-documents-directory-ios">this question</a>, but I haven't been able to implement that solution in Swift. </p>
  
  <p>Here's the code:</p>
  
  <pre><code>func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
  
      var theURL = posts.objectAtIndex(indexPath.row).valueForKey("enclosure") as? String
      var theMp3Filename = theURL!.lastPathComponent
  
      for i in downloadedList {
          if i as! String == theMp3Filename {
              // If we've d/l'ed the mp3, insert the local path
              theURL = documentsDirectory().stringByAppendingPathComponent(theMp3Filename)
              var path: NSURL = NSURL.fileURLWithPath(theURL!)!
              player = AVPlayer(URL: path)
              player.play()
  
          } else {
              let podcastEpisode = AVPlayerItem(URL: NSURL(string: theURL!))
              player = AVPlayer(playerItem: podcastEpisode)
              player.play()
          }
      }
  }
  </code></pre>
  
  <p><code>downloadedList</code> is just an array I generate with the downloaded filenames. I am getting into the local condition, and the path looks right, but AVPlayer usually isn't working.</p>
  
  <p>Any guidance would be appreciated. </p>