録音アプリがあり、ユーザーはロック画面から録音を一時停止できます。これにより、MPNowPlayingInfoCenter も消えるため、ユーザーはアプリに戻って記録を再開する必要があります。
ただし、ユーザーが一時停止ボタンを押すと、プロパティ タイトルの "Music" が点滅します。「音楽」がポップアップしなくても、別のアプリがうまく機能するのを見たことがあります。
私が何をする必要があるか分かりますか?
ここで、情報センターが呼び出されます「infoCenter はヘッダーで宣言され、合成されます。
infoCenter = [MPNowPlayingInfoCenter defaultCenter];
if (infoCenter) {
[[UIApplication sharedApplication] beginReceivingRemoteControlEvents];
infoCenter.nowPlayingInfo =
[NSDictionary dictionaryWithObjectsAndKeys:@"Recording", MPMediaItemPropertyTitle,
nil];
[self becomeFirstResponder];
}
}
コントロールは次のとおりです。
- (void) remoteControlReceivedWithEvent: (UIEvent *) receivedEvent {
if (receivedEvent.type == UIEventTypeRemoteControl) {
switch (receivedEvent.subtype) {
case UIEventSubtypeRemoteControlPause: {
[[UIApplication sharedApplication] endReceivingRemoteControlEvents];
[self resignFirstResponder];
[self playTapped:nil]; //this is the action that pauses the recording
break;
}
default:
break;
}
}
}