Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AVFoundation iOS 5

My apps runing on the appstore are using mp3 and video files that don't work since iOS5 update.

I've installed xcode 4.2 and... When I test in the iPhone 5 Simulator or device I get the following error (for audio or video files):

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: /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreFoundation.framework/CoreFoundation
in /System/Library/Frameworks/Security.framework/Versions/A/Security

When I try this in the iPhone 4.3 simulator or device it does not crash ..

I've cleaned and re import the frameworks involved but it seems to be that kind of error

Note: My apps don't use any security.

Could you help?

like image 386
E-Guitar Avatar asked Oct 15 '11 18:10

E-Guitar


3 Answers

I just have found an answer here.

If your app crashes here, disable All Exceptions in XCode 4 Breakpoints Tab. Maybe it's SDK bug.

like image 135
sasha_nec Avatar answered Nov 13 '22 17:11

sasha_nec


Try to make your player a retained property. I experienced the same and because I declared my player locally I think ARC retained as soon as the method in which I declared the player ran out of scope.

Make player a retained property

@property (strong)AVAudioPlayer *player;

Remember to set the delegate (self.player.delegate = self) and use the delegate's methods to clean up:

-(void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)playedSuccessfully {
    self.player = nil;
}
like image 41
Kasper Munck Avatar answered Nov 13 '22 18:11

Kasper Munck


I found the solution: NSURL instead of NSString:

NSURL *chemin = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@/MySound.wav", [[NSBundle mainBundle] resourcePath]]];
NSError *error;
AVAudioPlayer* mySound = [[AVAudioPlayer alloc] initWithContentsOfURL:chemin error:&error];
mySound.delegate = self;
[chemin release];
[mySound Play];
like image 21
E-Guitar Avatar answered Nov 13 '22 17:11

E-Guitar