/// <summary> /// Cannot make the assumption that a privilege is still granted after /// returning from pause. Return the application to the state where it /// requests privileges needed and clear out the list of already granted /// privileges. Also, disable the camera and unregister callbacks. /// </summary> void OnApplicationPause(bool pause) { if (pause) { _appPaused = true; #if PLATFORM_LUMIN if (_isCameraConnected && MLCamera.IsStarted) { MLResult result = MLCamera.ApplicationPause(_appPaused); if (!result.IsOk) { Debug.LogErrorFormat("Error: VideoCaptureExample failed to pause MLCamera, disabling script. Reason: {0}", result); enabled = false; return; } // If we did not record long enough make sure our path is marked as invalid to avoid trying to load invalid file. if (Time.time - _captureStartTime < _minRecordingTime) { _captureFilePath = null; } if (_isCapturing) { if (_rawVideoCaptureMode) { OnRawVideoCaptureEnded.Invoke(); } else { OnVideoCaptureEnded.Invoke(_captureFilePath); } } _isCapturing = false; _captureStartTime = 0; _captureFilePath = null; _isCameraConnected = false; } MLInput.OnControllerButtonDown -= OnButtonDown; MLInput.OnTriggerDown -= OnTriggerDown; #endif } }
/// <summary> /// Stop capturing video. /// </summary> public void EndCapture(bool captureCanceled = false) { if (_isCapturing) { #if PLATFORM_LUMIN MLResult result = MLCamera.StopVideoCapture(); if (result.IsOk) { // If we did not record long enough make sure our path is marked as invalid to avoid trying to load invalid file. if (Time.time - _captureStartTime < _minRecordingTime) { _captureFilePath = null; } if (!captureCanceled) { if (_rawVideoCaptureMode) { OnRawVideoCaptureEnded.Invoke(); } else { OnVideoCaptureEnded.Invoke(_captureFilePath); } } _isCapturing = false; _captureStartTime = 0; _captureFilePath = null; } else { Debug.LogErrorFormat("Error: VideoCaptureExample failed to end video capture. Error Code: {0}", MLCamera.GetErrorCode().ToString()); } #endif } else { Debug.LogError("Error: VideoCaptureExample failed to end video capture because the camera is not recording."); } }