m making an app which requires to play recorded audio files.
For that m having a sound.h/.m file and setting.h/.m file
In sound I have a method – update player which will update my audio-player if a new recorded files has been created.as follows..
-(AVAudioPlayer *)updatePlayer
{
if (!mAudioPlayer)
{
self.mAudioPlayer = [[[AVAudioPlayer alloc]initWithContentsOfURL:mURLObj error:nil]autorelease];
}
return mAudioPlayer;
}
Now , mcalling this metod every time when a new recorded audio file is created in settingcontroller..as follows..
-(void)hasNewRecorded:(BOOL)inFlag
{
if (inFlag == YES)
{
mRecorder.mAudioPlayer = [[mRecorder updatePlayer]retain];
}
[mRecorder.mAudioPlayer release];
}
I know that m doing wrong somewhere..But couldnot able to fix the problem for last 2 days. I’m looking forward for your help.
You are initiating a new audio player only if doesn’t exists here,
A new player wont be allocated as a player exists already. So the old audio file will keep playing. Try fixing a breakpoint inside this for loop and check, If that’s the problem change the condition – release the old audio player and allocate new one.