/// <summary>
        /// Responds to privilege requester result.
        /// </summary>
        /// <param name="result">Result of the privilege request.</param>
        private void HandlePrivilegesDone(MLResult result)
        {
            if (!result.IsOk)
            {
                CheckPrivilegeDenied(result);
                Debug.LogErrorFormat("Error: RawVideoCaptureExample failed to get all requested privileges, disabling script. Reason: {0}", result);
                enabled = false;
                return;
            }

            Debug.Log("Succeeded in requesting all privileges");

            // Called here because it needs privileges to be granted first on resume by PrivilegeRequester.
            if (_appPaused)
            {
                _appPaused = false;

                result = MLCamera.ApplicationPause(_appPaused);
                if (!result.IsOk)
                {
                    Debug.LogErrorFormat("Error: RawVideoCaptureExample failed to resume MLCamera, disabling script. Reason: {0}", result);
                    enabled = false;
                    return;
                }

                _isCameraConnected = true;

                MLInput.OnControllerButtonDown += OnButtonDown;
            }
            else
            {
                EnableCapture();
            }
        }
Пример #2
0
        /// <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 (_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 (_isCapturing)
                    {
                        OnVideoCaptureEnded.Invoke(_captureFilePath);
                        _captureFilePath = null;
                    }

                    _isCapturing       = false;
                    _captureStartTime  = 0;
                    _isCameraConnected = false;
                }

                MLInput.OnControllerButtonDown -= OnButtonDown;
            }
        }
Пример #3
0
        /// <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
            }
        }