how to autoplay all songs one after another?
i am creating a music application in which i m having 20 songs.First i have to download all the songs from my server which i am done with now my next requirement is after downloading gets over all the songs should play one开发者_运维问答 after another.
To play one song m using the below code:
player=[[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:Mp3filePath] error:nil];
[player play];
please help me as soon as possible.......
The key is to make your main controller adopt the AVAudioPlayerDelegate protocol. When you create an AVAudioPlayer, set its delegate property to your controller (player.delegate = self
) Then you can implement the method "- (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag"
and it will get called each time the AVAudioPlayer finishes playing a file.
Presumably inside that method you would create a new AVAudioPlayer, (remember to set its delegate to your controller), init with the next url, then tell it to play.
you canset code for play next song in this delegate method for play next song :- - (void)audioPlayerDidFinishPlaying:(AVAudioPlayer *)player successfully:(BOOL)flag {}
精彩评论