title: Audio is playing in simulator but not on device
body: <p>I'm developing an app that plays audio files and can get the files to play with an instance of AVPlayer in the xcode simulator (v10.2) but when trying to play this on my device the audio file does not play. </p>
  
  <p>I have read responses to the same issue and have checked: </p>
  
  <ul>
  <li>that the mute ringer switch on the device is not turned on</li>
  <li>that I have not instantiated the AVPlayer in the viewDidLoad</li>
  <li>that the name of the audio file is the same case in the code as in the file</li>
  </ul>
  
  <p>Following is the code where I set up the recorder: </p>
  
  <pre><code>func setUpRecorder(storyItem : StoryItem) {
  
      // Generate unique ID for recording for the StoryItem
      let uuid = UUID().uuidString + ".m4a"
  
      let audioFileName = getDocumentDirectory().appendingPathComponent(uuid)
  
      do {
          try self.realm.write {
              // storyItem.recording = audioFileName.absoluteString
              storyItem.recording = uuid
          }
      } catch {
          print("Error saving recording \(error)")
      }
      self.createStoryTableView.reloadData()
  
      let recordSettings = [AVFormatIDKey : kAudioFormatAppleLossless,
                            AVEncoderAudioQualityKey : AVAudioQuality.max.rawValue,
                            AVEncoderBitRateKey : 320000,
                            AVNumberOfChannelsKey : 2,
                            AVSampleRateKey : 44100.0 ] as [String : Any]
  
      do {
          audioRecorder = try AVAudioRecorder(url: audioFileName, settings: recordSettings)
          audioRecorder.delegate = self
          audioRecorder.prepareToRecord()
      } catch {
          print(error)
      }
  }
  </code></pre>
  
  <p>Method for playing the audio file is here: </p>
  
  <p>func setUpPlayer(storyItem : StoryItem) {</p>
  
  <pre><code>    let audioFileName = getDocumentDirectory().appendingPathComponent(storyItem.recording)
  
      getAudioDuration(audioFileName: audioFileName)
  
      if storyItem.recording == "" {
  
          let alert = UIAlertController(title: "There's no recording", message: "", preferredStyle: .alert)
          let action = UIAlertAction(title: "Cancel", style: .default) { (action) in
          }
          // This is what happens when cancel is pressed
  
          alert.addAction(action)
  
          self.present(alert, animated: true, completion: nil)
      } else {
  
      player = AVPlayer(url: audioFileName)
      player.volume = 1.0
  
      }
  }
  </code></pre>
  
  <p>I'd be grateful for any suggestions. Could it be the use of the unique identifier (UUID) as the name of the audio file? </p>