title: Playing music from parse in swift
body: <p>I'm trying to play audio file from <a href="http://parse.com" rel="nofollow">Parse.com</a>. After running this code I get <strong><em>Error occured while getting data!</em></strong> printed out. I can't understand why might that be happening. I think URL is correct. When I tried it in browser it started to download music that I'm trying to play. Can anybody tell me what is wrong with this code or how to solve this problem?</p>
  
  <pre><code>    let query = PFQuery(className: "AudioFile")
      query.whereKeyExists("audio")
      query.findObjectsInBackgroundWithBlock { (objects:[PFObject]?, error: NSError?) -&gt; Void in
          if error == nil {
              let audio = objects?[0]
              let audioFile = audio?["audio"] as? PFFile
              let filePath = audioFile?.url
              let url = NSURL(fileURLWithPath: filePath!)
              let soundData = NSData(contentsOfURL: url)
              if soundData != nil {
                  do {
                      self.audioPlayer = try AVAudioPlayer(data: soundData!) // AVAudioPlayer(contentsOfURL: url)
                      self.audioPlayer.prepareToPlay()
                      self.audioPlayer.volume = 1.0
                      self.audioPlayer.play()
                  } catch {
                      print("Error occured while playing music!")
                  }
              } else {
                  print("Error occured while getting data!")
              }
          } else {
              print("Error occured while downloading file!")
          }
      }
  </code></pre>