Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2012
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.51 KB | None | 0 0
  1. iOS - Attempting to play mp3 file fails
  2. - (IBAction)play:(UIButton *)sender {
  3. dispatch_queue_t downloadQueue = dispatch_queue_create("audio data downloader", NULL);
  4. dispatch_async(downloadQueue, ^{
  5. NSURL *audioURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@/%@.mp3", FONYK_FILES_URL, [self.voicenote valueForKeyPath:@"Fonyker.fonykid"], [self.voicenote valueForKeyPath:@"Voicenote.vnid"]]];
  6. NSData *audioData = [NSData dataWithContentsOfURL:audioURL];
  7.  
  8. dispatch_async(dispatch_get_main_queue(), ^{
  9. NSError *error = nil;
  10. AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithData:audioData error:&error];
  11. NSLog(@"%@", error);
  12. audioPlayer.delegate = self;
  13. [audioPlayer play];
  14. });
  15. });
  16. }
  17.  
  18. Catchpoint 2 (exception thrown).Single stepping until exit from function __cxa_throw, which has no line number information.
  19.  
  20. Error Domain=NSOSStatusErrorDomain Code=-50 "The operation couldn’t be completed. (OSStatus error -50.)"
  21.  
  22. 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
  23. Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
  24. Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
  25. in /System/Library/Frameworks/Security.framework/Versions/A/Security
  26. 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
  27. Referenced from: /System/Library/Frameworks/Security.framework/Versions/A/Security
  28. Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
  29. in /System/Library/Frameworks/Security.framework/Versions/A/Security
  30.  
  31. NSURL *fileURL = [NSURL URLWithString:filePath];
  32.  
  33. NSURL *fileURL = [NSURL fileURLWithPath:filePath];
  34.  
  35. AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithData:[NSData dataWithContentsOfURL:audioURL] error:&error];
  36.  
  37. - (IBAction)play:(UIButton *)sender {
  38. dispatch_queue_t downloadQueue = dispatch_queue_create("audio data downloader", NULL);
  39. dispatch_async(downloadQueue, ^{
  40. NSURL *audioURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@/%@.mp3", FONYK_FILES_URL, [self.voicenote valueForKeyPath:@"Fonyker.fonykid"], [self.voicenote valueForKeyPath:@"Voicenote.vnid"]]];
  41. NSData *audioData = [NSData dataWithContentsOfURL:audioURL];
  42.  
  43. dispatch_async(dispatch_get_main_queue(), ^{
  44. NSError *error = nil;
  45. AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithData:audioData error:&error];
  46. NSLog(@"%@", error);
  47. audioPlayer.delegate = self;
  48. [audioPlayer play];
  49. });
  50. });
  51. }
  52.  
  53. NSURL *audioURL = [NSURL URLWithString:@"MY_MP3_URL"];
  54. MPMoviePlayerController* player = [[MPMoviePlayerController alloc] initWithContentURL:audioURL];
  55. [player play];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement