void ShowActualAVPermissionAlertWithType(ClusterAVAuthorizationType mediaType) { AVCaptureDevice.RequestAccessForMediaType(AVEquivalentMediaType(mediaType), granted => BeginInvokeOnMainThread(delegate { FireAVPermissionCompletionHandlerWithType(mediaType); })); }
void FireAVPermissionCompletionHandlerWithType(ClusterAVAuthorizationType mediaType) { AVAuthorizationStatus status = AVCaptureDevice.GetAuthorizationStatus(AVEquivalentMediaType(mediaType)); if (_avPermissionCompletionHandler != null) { ClusterDialogResult userDialogResult = ClusterDialogResult.Granted; ClusterDialogResult systemDialogResult = ClusterDialogResult.Granted; if (status == AVAuthorizationStatus.NotDetermined) { userDialogResult = ClusterDialogResult.Denied; systemDialogResult = ClusterDialogResult.NoActionTaken; } else if (status == AVAuthorizationStatus.Authorized) { userDialogResult = ClusterDialogResult.Granted; systemDialogResult = ClusterDialogResult.Granted; } else if (status == AVAuthorizationStatus.Denied) { userDialogResult = ClusterDialogResult.Granted; systemDialogResult = ClusterDialogResult.Denied; } else if (status == AVAuthorizationStatus.Restricted) { userDialogResult = ClusterDialogResult.Granted; systemDialogResult = ClusterDialogResult.ParentallyRestricted; } _avPermissionCompletionHandler((status == AVAuthorizationStatus.Authorized), userDialogResult, systemDialogResult); _avPermissionCompletionHandler = null; } }
NSString AVEquivalentMediaType(ClusterAVAuthorizationType mediaType) { if (mediaType == ClusterAVAuthorizationType.Camera) { return(AVMediaType.Video); } else { return(AVMediaType.Audio); } }
public void ShowAVPermissionsWithType(ClusterAVAuthorizationType mediaType, string requestTitle, string message, string denyButtonTitle, string grantButtonTitle, ClusterPrePermissionCompletionHandler completionHandler) { if (requestTitle.Length == 0) { switch (mediaType) { case ClusterAVAuthorizationType.Camera: requestTitle = @"Access Camera?"; break; default: requestTitle = @"Access Microphone?"; break; } } denyButtonTitle = GetTitleForType(ClusterTitleType.Deny, denyButtonTitle); grantButtonTitle = GetTitleForType(ClusterTitleType.Request, grantButtonTitle); AVAuthorizationStatus status = AVCaptureDevice.GetAuthorizationStatus(AVMediaType.Video); if (status == AVAuthorizationStatus.NotDetermined) { _avPermissionCompletionHandler = completionHandler; _preAVPermissionAlertView = new UIAlertView(requestTitle, message, new AlertViewDelegate(this), denyButtonTitle, grantButtonTitle); _preAVPermissionAlertView.Tag = (nint)(int)mediaType; _preAVPermissionAlertView.Show(); } else { if (completionHandler != null) { completionHandler((status == AVAuthorizationStatus.Authorized), ClusterDialogResult.NoActionTaken, ClusterDialogResult.NoActionTaken); } } }
void ShowActualAVPermissionAlertWithType(ClusterAVAuthorizationType mediaType) { AVCaptureDevice.RequestAccessForMediaType (AVEquivalentMediaType (mediaType), granted => BeginInvokeOnMainThread (delegate { FireAVPermissionCompletionHandlerWithType (mediaType); })); }
void FireAVPermissionCompletionHandlerWithType(ClusterAVAuthorizationType mediaType) { AVAuthorizationStatus status = AVCaptureDevice.GetAuthorizationStatus (AVEquivalentMediaType (mediaType)); if (_avPermissionCompletionHandler != null) { ClusterDialogResult userDialogResult = ClusterDialogResult.Granted; ClusterDialogResult systemDialogResult = ClusterDialogResult.Granted; if (status == AVAuthorizationStatus.NotDetermined) { userDialogResult = ClusterDialogResult.Denied; systemDialogResult = ClusterDialogResult.NoActionTaken; } else if (status == AVAuthorizationStatus.Authorized) { userDialogResult = ClusterDialogResult.Granted; systemDialogResult = ClusterDialogResult.Granted; } else if (status == AVAuthorizationStatus.Denied) { userDialogResult = ClusterDialogResult.Granted; systemDialogResult = ClusterDialogResult.Denied; } else if (status == AVAuthorizationStatus.Restricted) { userDialogResult = ClusterDialogResult.Granted; systemDialogResult = ClusterDialogResult.ParentallyRestricted; } _avPermissionCompletionHandler ((status == AVAuthorizationStatus.Authorized), userDialogResult, systemDialogResult); _avPermissionCompletionHandler = null; } }
NSString AVEquivalentMediaType(ClusterAVAuthorizationType mediaType) { if (mediaType == ClusterAVAuthorizationType.Camera) { return AVMediaType.Video; } else { return AVMediaType.Audio; } }
public void ShowAVPermissionsWithType(ClusterAVAuthorizationType mediaType, string requestTitle, string message, string denyButtonTitle, string grantButtonTitle, ClusterPrePermissionCompletionHandler completionHandler) { if (requestTitle.Length == 0) { switch (mediaType) { case ClusterAVAuthorizationType.Camera: requestTitle = @"Access Camera?"; break; default: requestTitle = @"Access Microphone?"; break; } } denyButtonTitle = GetTitleForType (ClusterTitleType.Deny, denyButtonTitle); grantButtonTitle = GetTitleForType (ClusterTitleType.Request, grantButtonTitle); AVAuthorizationStatus status = AVCaptureDevice.GetAuthorizationStatus (AVMediaType.Video); if (status == AVAuthorizationStatus.NotDetermined) { _avPermissionCompletionHandler = completionHandler; _preAVPermissionAlertView = new UIAlertView (requestTitle, message, new AlertViewDelegate (this), denyButtonTitle, grantButtonTitle); _preAVPermissionAlertView.Tag = (nint)(int)mediaType; _preAVPermissionAlertView.Show (); } else { if (completionHandler != null) { completionHandler ((status == AVAuthorizationStatus.Authorized), ClusterDialogResult.NoActionTaken, ClusterDialogResult.NoActionTaken); } } }