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
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. 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: EXC_BREAKPOINT
is on audioPlayer.delegate = self .
If giving data: CDEpisode = fetchedResultsController.objectAtIndexPath (indexPath!)! CDEpicिस {var err: NSError? Go url = NSURL (string: data.localPath) println ("url \ s (url)") // rest of code}
No comments:
Post a Comment