AVAudioPlayer problem regarding song overlaping in iPhone
- by riteshkumar1905
I have using AVAudioPlayer in my app but the problem is that when i play the song from list it will played while before stopping the song i am again goes to song list then select another song then both song will start playing simultaneously so please tell me the code which will terminate my first song. i am using avTouchContoller & avTouchViewController in my app. so i am enclosing the code for song which is written in avController.m & avTouchViewController.m as follow for single song
avtouchController.m
switch (flag)
{
case 1:
//[self stop];
fileURL = [[NSURL alloc] initFileURLWithPath: [[NSBundle mainBundle] pathForResource:@"Aarti Keeje" ofType:@"aac"]];
self._player = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:nil];
//self._player=newplayer;
//[newplayer release];
if (self._player)
{
_fileName.text = [NSString stringWithFormat: @"%@ (%d ch.)", [[self._player.url relativePath] lastPathComponent], self._player.numberOfChannels, nil];
[self updateViewForPlayerInfo];
[self updateViewForPlayerState];
}
[fileURL release];
break;