AVAudioPlayer problem regarding song overlaping in iPhone
        Posted  
        
            by riteshkumar1905
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by riteshkumar1905
        
        
        
        Published on 2010-05-12T05:24:45Z
        Indexed on 
            2010/05/12
            5:34 UTC
        
        
        Read the original article
        Hit count: 369
        
iphone
|objective-c
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;
        © Stack Overflow or respective owner