how to autoplay next song in music application when first song completes playing
I have made a music app using avtouchController & I want to play m开发者_高级运维y next song one after the other using autoplay can u please give me the step to autoplay a song.
It's hard to tell from your question, but it sounds like you want to use AVQueuePlayer.
You should go to settings and set the play mode as sequential play mode.
If you're using AVFoundation, you can just add a listener to your player, and make the end playback method to fetch the next track. You add the listener like so:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(playerItemDidReachEnd:)
name:AVPlayerItemDidPlayToEndTimeNotification
object:[player currentItem]];
And then you create your method, something like this:
-(void)playerItemDidReachEnd:(NSNotification *)notification {
AVPlayerItem *p = [notification object];
//Fetch your next track from your plist, array, database or whatever
}
精彩评论