public void OnApplicationFocus(bool hasFocus) { if (hasFocus) { InitializeMediaCapture(); } else { _holoLensMediaFrameSourceGroup.StopAsync(); webcamInitialized = false; } }
/// <summary> /// Stop the media frame source groups. /// </summary> /// <returns></returns> async Task StopHoloLensMediaFrameSourceGroup() { #if ENABLE_WINMD_SUPPORT if (!_mediaFrameSourceGroupsStarted || _pvMediaFrameSourceGroup == null || _shortDepthMediaFrameSourceGroup == null) { return; } // Wait for frame source groups to stop. await _pvMediaFrameSourceGroup.StopAsync(); _pvMediaFrameSourceGroup = null; await _shortDepthMediaFrameSourceGroup.StopAsync(); _shortDepthMediaFrameSourceGroup = null; // Set to null value _sensorFrameStreamerPv = null; _sensorFrameStreamerResearch = null; // Bool to indicate closing _mediaFrameSourceGroupsStarted = false; myText.text = "Stopped streaming sensor frames. Okay to exit app."; #endif }