Reputation: 12211
I am using AVAudioPlayer object to play an audio. I created an audioPlayer object initially. I play an animation and when ever animation starts I play the audio and pause the audio when the animation is finished. I initially found three memory Leaks using Instruments. (The responsible caller mentioned was RegisterEmbedCodecs). After suggestion from a "ahmet emrah" in this forum to add MediaPlayer framework, the number of leaks reduced to one. And is there any way to completely get rid of it?
Thanks and regards, krishnan.
Upvotes: 4
Views: 2633
Reputation: 12211
I got this problem resolved. This occured only in Simulator and not in the device.
Upvotes: 2
Reputation: 46703
You may want to post some code up. This is typically how I play an audio file and I do not have any leaks appearing:
NSString *path = [[NSBundle mainBundle] pathForResource:@"somefile" ofType:@"mp3"];
AVAudioPlayer * newAudio=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path] error:NULL];
self.theAudio = newAudio; // automatically retain audio and dealloc old file if new file is loaded
[newAudio release]; // release the audio safely
theAudio.delegate = self;
[theAudio prepareToPlay];
[theAudio setNumberOfLoops:0];
[theAudio play];
Upvotes: 0