Tuesday, 15 September 2015

ios - OSStatus error 2003334207 when using AVAudioPlayer -


I am trying to run an MP3 file (when played through VLC / iTunes) when a button Here's my code:

  var audio player: AVAudioPlayer! @IBAction function playEpisode (this: AnyObject) {println ("Playing Now") go to indexPath = NSIndexPath as CDEpisode = fetchedResultsController.objectAtIndexPath (forRow: sender.tag, insection: 0) Go Data (indexPath!)! CDEpisode var Errors: NSError? Go = url = NSURL (string: data.localPath) println ("url is \") Audioplayer = AVAudioPlayer (contentsOfURL: url, error: & amp; o) if Audioplayer == is not equal to {go to E = Un {println (e.localizedDescription)}} audioPlayer.delegate = self audioPlayer.prepareToPlay () audioPlayer.play ()}  

is logged here:

  The URL play option is optional (file: ///var/mobile/Containers/Data/Application/4747A71E-A63F-4EFC-B2DF-8B361361080B/Documents/serial-s01-e12.mp3) The operation can not be completed. (OSStatus error 2003334207.) Fatal error: Unexpectedly unwrapping an optional value, while  

EXC_BREAKPOINT is on audioPlayer.delegate = self .

Other threads on StackoOverflow do not help. any idea? Thanks

Edit : I have tried to pass a local URL for the content of IFURL (instead of a CDEpisode object) and it still fails.

It seems that you have to try to open a variable that is zero value. You must open your variable safely to prevent this.

  If giving data: CDEpisode = fetchedResultsController.objectAtIndexPath (indexPath!)! CDEpicिस {var err: NSError? Go url = NSURL (string: data.localPath) println ("url \ s (url)") // rest of code}  

You will still need to figure out why this That is returning to zero but it is a safe way to open the variable and prevent it from crashing because there will be more context to solve that problem.

To see some questions:

  • Are you sure the fetchedResultsController object is returning at all?
  • Are you sure that this is from CDEpisode?

No comments:

Post a Comment