Note that there are some explanatory texts on larger screens.

plurals
  1. POiOS - Attempting to play mp3 file fails
    primarykey
    data
    text
    <p>I'm trying to playback and mp3 file I retrieve from my server from my app doing the following:</p> <pre><code>- (IBAction)play:(UIButton *)sender { dispatch_queue_t downloadQueue = dispatch_queue_create("audio data downloader", NULL); dispatch_async(downloadQueue, ^{ NSURL *audioURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@/%@.mp3", FONYK_FILES_URL, [self.voicenote valueForKeyPath:@"Fonyker.fonykid"], [self.voicenote valueForKeyPath:@"Voicenote.vnid"]]]; NSData *audioData = [NSData dataWithContentsOfURL:audioURL]; dispatch_async(dispatch_get_main_queue(), ^{ NSError *error = nil; AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithData:audioData error:&amp;error]; NSLog(@"%@", error); audioPlayer.delegate = self; [audioPlayer play]; }); }); } </code></pre> <p>The playback fails, meaning no sound is emitted and I get this output when debugging my app step by step:</p> <pre><code>Catchpoint 2 (exception thrown).Single stepping until exit from function __cxa_throw, which has no line number information. </code></pre> <p>And this comes up when I NSLog the error in the simulator:</p> <pre><code>Error Domain=NSOSStatusErrorDomain Code=-50 "The operation couldn’t be completed. (OSStatus error -50.)" </code></pre> <p>Nothing else shows it just fails, any thoughts?</p> <p><strong>UPDATE:</strong> Modified my code as per J_D's answer and got this in the simulator:</p> <pre><code>Error loading /System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn: dlopen(/System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn, 262): Symbol not found: ___CFObjCIsCollectable Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation in /System/Library/Frameworks/Security.framework/Versions/A/Security 2012-04-17 15:03:43.054 Fonyk[8238:15307] Error loading /System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn: dlopen(/System/Library/Extensions/AudioIPCDriver.kext/Contents/Resources/AudioIPCPlugIn.bundle/Contents/MacOS/AudioIPCPlugIn, 262): Symbol not found: ___CFObjCIsCollectable Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation in /System/Library/Frameworks/Security.framework/Versions/A/Security </code></pre> <p><strong>UPDATE:</strong> the real issue I had was not creating and AVAudioSession instance set to playback in my code, doing so along with the corrections answer I accepted made it work.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload