title: Remote mp3 file taking a lot of time to play in swift ios
body: <p>i'm in trouble. i want to play a remote mp3 file in my app. but mp3 file taking a lot of time (approx 5-6 minute) to play. why ? </p>
  
  <p>Anyone can suggest what should i do ? </p>
  
  <pre><code> import UIKit
  
   import AVFoundation
  
   class TestViewController: UIViewController, AVAudioPlayerDelegate {
  
   var player:AVAudioPlayer = AVAudioPlayer()
  
   override func viewDidLoad() {
      super.viewDidLoad()
   }
  
   @IBAction func play(sender: AnyObject) {
  
      let url = "http://www.example.com/song.mp3"
  
      let fileURL = NSURL(string: url.stringByAddingPercentEncodingWithAllowedCharacters(NSCharacterSet.URLQueryAllowedCharacterSet()))
  
      let soundData = NSData.dataWithContentsOfURL(fileURL, options: nil, error: nil)
  
      var error: NSError?
      self.player = AVAudioPlayer(data: soundData, error: &amp;error)
      if player == nil
      {
          if let e = error
          {
              println(e.localizedDescription)
          }
      }
  
      player.volume   = 1.0
      player.delegate = self
      player.prepareToPlay()
  
      player.play()
  
   }
  
  }
  </code></pre>
  
  <p>Thanks in advance.</p>