public void ToggleRecording() { #if SHOULD_USE_RECORDING_PLUGIN if (!isRecording) { #if UNITY_IOS && !UNITY_EDITOR if (MergeIOSBridge.CheckPhoto() == 2) { MergeIOSBridge.RequestPhoto(); return; } else if (MergeIOSBridge.CheckPhoto() != 1) { MergeIOSBridge.OpenPhotoSettings(); return; } #endif #if UNITY_ANDROID && !UNITY_EDITOR if (!MergeAndroidBridge.HasPermission(AndroidPermission.WRITE_EXTERNAL_STORAGE)) { MergeAndroidBridge.CheckPermissionAndReDirectToSettingsScreen(AndroidPermission.READ_EXTERNAL_STORAGE); return; } if (!MergeAndroidBridge.HasPermission(AndroidPermission.RECORD_AUDIO)) { MergeAndroidBridge.CheckPermissionAndReDirectToSettingsScreen(AndroidPermission.RECORD_AUDIO); return; } #endif StartRec(System.DateTime.Now.Day.ToString() + "_" + System.DateTime.Now.Month.ToString() + "_" + System.DateTime.Now.Year.ToString() + "_" + System.DateTime.Now.Hour.ToString() + "_" + System.DateTime.Now.Minute.ToString(), HandleRecSaveComplete); } else { // Debug.LogWarning("Should Stop Recording."); StopRec(); // Debug.LogWarning("Should Set Recording to False."); } #endif }
public void ToggleRecording() { #if SHOULD_USE_RECORDING_PLUGIN if (isBusy) { return; } CancelInvoke("ResetBusyStatus"); CancelInvoke("ToggleRecording"); if (!isRecording) { #if UNITY_IOS && !UNITY_EDITOR if (MergeIOSBridge.CheckPhoto() == 2) { MergeIOSBridge.RequestPhoto(); return; } else if (MergeIOSBridge.CheckPhoto() != 1) { MergeIOSBridge.OpenPhotoSettings(); return; } #endif #if UNITY_ANDROID && !UNITY_EDITOR if (!MergeAndroidBridge.HasPermission(AndroidPermission.WRITE_EXTERNAL_STORAGE)) { MergeAndroidBridge.CheckPermissionAndReDirectToSettingsScreen(AndroidPermission.READ_EXTERNAL_STORAGE); return; } if (!MergeAndroidBridge.HasPermission(AndroidPermission.RECORD_AUDIO)) { MergeAndroidBridge.CheckPermissionAndReDirectToSettingsScreen(AndroidPermission.RECORD_AUDIO); return; } #endif StartRec(System.DateTime.Now.Day.ToString() + "_" + System.DateTime.Now.Month.ToString() + "_" + System.DateTime.Now.Year.ToString() + "_" + System.DateTime.Now.Hour.ToString() + "_" + System.DateTime.Now.Minute.ToString(), null); // RecordingButton.gameObject.SetActive( false ); timer.StartTimer(); isBusy = true; Invoke("ResetBusyStatus", 3f); //Stop recording after 30 seconds if still running. Invoke("ToggleRecording", 30f); } else { // Debug.LogWarning("Should Stop Recording."); // RecordingButton.gameObject.SetActive( true ); timer.StopTimer(); isBusy = true; StopRec(); // Debug.LogWarning("Should Set Recording to False."); } #endif }