views:

233

answers:

2

Hi Friends,

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.

A: 

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];
iWasRobbed
Hi Friend,I got this problem resolved. This occured only in Simulator and not in the device Thanks for your time.
Krishnan
A: 

Hi Friends, I got this problem resolved. This occured only in Simulator and not in the device.

Krishnan