2

I am using AVAudioPlayer in my iOS application and the following functionalities have been given.

1. Play 2. Pause 3. Next 4. Previous

My requirement is, I want to give these functionalities from control center. Is it possible?

Community
  • 1
  • 1
jailani
  • 2,260
  • 2
  • 21
  • 45

1 Answers1

5

Control Center uses same API as lock screen. The audio controls appear on lock screen when a properly configured AVAudioSession is active. In addition to that you need to use MPNowPlayingInfoCenter API to set correct media information.

MPMediaItemArtwork *artwork = [[MPMediaItemArtwork alloc]initWithImage:albumImage];

[MPNowPlayingInfoCenter defaultCenter].nowPlayingInfo = @{ 
    MPMediaItemPropertyTitle : aSong.songTitle,
    MPMediaItemPropertyArtist : aSong.artistName,
    MPMediaItemPropertyArtwork : artwork,
    MPNowPlayingInfoPropertyPlaybackRate : 1.0f
};

See the questions below for more information:

Community
  • 1
  • 1
Legoless
  • 10,942
  • 7
  • 48
  • 68