void SessionWasInterrupted (NSNotification notification)
{
// In some scenarios we want to enable the user to resume the session running.
// For example, if music playback is initiated via control center while using AVCam,
// then the user can let AVCam resume the session running, which will stop music playback.
// Note that stopping music playback in control center will not automatically resume the session running.
// Also note that it is not always possible to resume, see ResumeInterruptedSession.
var reason = (AVCaptureSessionInterruptionReason)((NSNumber)notification.UserInfo [AVCaptureSession.InterruptionReasonKey]).Int32Value;
Console.WriteLine ("Capture session was interrupted with reason {0}", reason);
var showResumeButton = false;
if (reason == AVCaptureSessionInterruptionReason.AudioDeviceInUseByAnotherClient ||
reason == AVCaptureSessionInterruptionReason.VideoDeviceInUseByAnotherClient) {
showResumeButton = true;
} else if (reason == AVCaptureSessionInterruptionReason.VideoDeviceNotAvailableWithMultipleForegroundApps) {
// Simply fade-in a label to inform the user that the camera is unavailable.
CameraUnavailableLabel.Alpha = 0;
CameraUnavailableLabel.Hidden = false;
UIView.Animate (0.25, () => CameraUnavailableLabel.Alpha = 1);
}
if (showResumeButton) {
// Simply fade-in a button to enable the user to try to resume the session running.
ResumeButton.Alpha = 0;
ResumeButton.Hidden = false;
UIView.Animate (0.25, () => ResumeButton.Alpha = 1);
}
}