1
votes

I have abillity to listen to mp3 song in my app. I am using AVPLAYER Here is some code

player = [[AVPlayer alloc] initWithURL:[NSURL fileURLWithPath:filePath]];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playingItemDidEnd) name:AVPlayerItemDidPlayToEndTimeNotification object:player]; 
    [player play];
    timer = [NSTimer scheduledTimerWithTimeInterval:0.5f target:self selector:@selector(checkTime) userInfo:nil repeats:YES];

So when i'm using ios 5.0 I have this in debug 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 2012-02-27 15:21:27.717 LifesMusic[4161:10703] 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

But it still working. But in IOS 4.3 it is not working at all. Can somebody help me to fix this problem? Thanks

2

2 Answers

0
votes

First of all: you should read Apples document Multimedia Programming Guide and understand what you're doing …

Also make sure you linked the AV Foundation framework to your project, imported it properly and your controller "listens" to the AVAudioPlayerDelegate.

In your controllers .h-file:

@property (nonatomic, retain) AVAudioPlayer *player;

In your controllers .m-file:

@synthesize player;

In your method which 'plays' the song:

NSString *soundFilePath = [[NSBundle mainBundle] pathForResource: @"song" ofType: @"mp3"];
NSURL *fileURL = [[NSURL alloc] initFileURLWithPath: soundFilePath];
AVAudioPlayer *newPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL: fileURL error: nil];
[fileURL release];
self.player = newPlayer;
[newPlayer release];

[player setDelegate: self];
[player prepareToPlay];
[player play];

Delegate method to repeat song:

- (void) audioPlayerDidFinishPlaying:(AVAudioPlayer*)player successfully:(BOOL)completed {
    if (completed == YES) {
        [player play];
    }
}
0
votes

I also received same error (OSStatus error 1685348671) when I tried to play mp3 files on iOS 4.3.

Later on I found that it was the mp3 sound problem which made it incompatible to be played in iOS 4.3. So, I used iTunes Player to convert new version of mp3 sound with existing one. Now it works fine and better.

Steps:

Open your current mp3 sound in iTunes Select it and Click on "Advanced" Menu >> "Create MP3 Version" It wil create copy of current audio. Use newly created mp3 file for your app.

It helped me. I hope it might help others as well. All the best!