हाँ, वहाँ निर्देश remote control events के बारे में सेब डॉक्स में पाया को देखते हुए कि
के लिए एक API आप दो वर्गों MPRemoteCommand
और MPRemoteCommandCenter
प्रकाश डाला मिलता है। MPRemoteCommandCenter देखकर आपको दिखाएगा कि likeCommand
या dislikeCommand
जैसे कई आदेश हैं, आप हैंडलर जोड़ सकते हैं। उन आदेशों पर हैंडलर जोड़ना उन्हें नियंत्रण केंद्र में प्रदर्शित मधुमक्खी का कारण बनता है।
- (void)showCustomizedControlCenter {
/* basic audio initialization */
NSString *soundFilePath = [NSString stringWithFormat:@"%@/test.mp3", [[NSBundle mainBundle] resourcePath]];
NSURL *soundFileURL = [NSURL fileURLWithPath:soundFilePath];
self.player = [[AVAudioPlayer alloc] initWithContentsOfURL:soundFileURL error:nil];
self.player.numberOfLoops = -1;
[self.player play];
/* registering as global audio playback */
[[AVAudioSession sharedInstance] setActive:YES error:nil];
[[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback error:nil];
/* the cool control center registration */
MPRemoteCommandCenter *commandCenter = [MPRemoteCommandCenter sharedCommandCenter];
[commandCenter.playCommand addTargetWithHandler:^MPRemoteCommandHandlerStatus(MPRemoteCommandEvent *event) {
return MPRemoteCommandHandlerStatusSuccess;
}];
[commandCenter.dislikeCommand addTargetWithHandler:^MPRemoteCommandHandlerStatus(MPRemoteCommandEvent *event) {
return MPRemoteCommandHandlerStatusSuccess;
}];
[commandCenter.likeCommand addTargetWithHandler:^MPRemoteCommandHandlerStatus(MPRemoteCommandEvent *event) {
return MPRemoteCommandHandlerStatusSuccess;
}];
[commandCenter.nextTrackCommand addTargetWithHandler:^MPRemoteCommandHandlerStatus(MPRemoteCommandEvent *event) {
return MPRemoteCommandHandlerStatusSuccess;
}];
/* setting the track title, album title and button texts to match the screenshot */
commandCenter.likeCommand.localizedTitle = @"Thumb Up";
commandCenter.dislikeCommand.localizedTitle = @"Thumb down";
MPNowPlayingInfoCenter* info = [MPNowPlayingInfoCenter defaultCenter];
NSMutableDictionary* newInfo = [NSMutableDictionary dictionary];
[newInfo setObject:@"Mixtape" forKey:MPMediaItemPropertyTitle];
[newInfo setObject:@"Jamie Cullum" forKey:MPMediaItemPropertyArtist];
info.nowPlayingInfo = newInfo;
}
इसके अलावा करने के लिए AVFoundation
जोड़ने कोड आप