开发者

how to autoplay next song in music application when first song completes playing

开发者 https://www.devze.com 2023-01-20 02:22 出处:网络
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

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
      }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号