views:

29

answers:

1

Hello,I am using Avaudio player in our app.I play the song from list after playing when i back to list for selecting another song then fist one is also playing.

I want to stop previous song and then play the other song.

Please help me.

A: 

[oldplayer stop];

[newplayer start];

you may also be able to get this behavior by setting your audio session up correctly: say

        UInt32 sessionCategory = kAudioSessionCategory_MediaPlayback;   // Defines a new variable of type UInt32 and initializes it with the identifier 
                                                                        // for the category you want to apply to the audio session.
        AudioSessionSetProperty (
            kAudioSessionProperty_AudioCategory,                        // The identifier, or key, for the audio session property you want to set.
            sizeof(sessionCategory),                                    // The size, in bytes, of the property value that you are applying.
            &sessionCategory                                            // The category you want to apply to the audio session.
        );

Andiih