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?
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: