private void RefreshMicrophonesButtonOnClickHandler() { CustomMicrophone.RequestMicrophonePermission(); microphonesDropdown.ClearOptions(); microphonesDropdown.AddOptions(CustomMicrophone.devices.ToList()); }
/// <summary> /// Currently works as synchronous function with callback when app unpauses /// could not work properly if has enabled checkbox regarding additional frame in pause /// </summary> /// <param name="callback"></param> public void RequestMicrophonePermission(Action <bool> callback) { #if UNITY_ANDROID Permission.RequestUserPermission(Permission.Microphone); #elif UNITY_WEBGL CustomMicrophone.RequestMicrophonePermission(); #endif callback?.Invoke(HasMicrophonePermission()); }
private void Start() { #if UNITY_WEBGL && !UNITY_EDITOR _buffer = new Buffer(); _audioSource.clip = AudioClip.Create("BufferedClip", _sampleRate * _recordingTime, 1, _sampleRate, false); #endif CustomMicrophone.RequestMicrophonePermission(); startRecord.onClick.AddListener(StartRecordHandler); stopRecord.onClick.AddListener(StopRecordHandler); }
// Start is called before the first frame update void Start() { var voice = GameObject.Find("[PeerJS]VoiceChat"); if (voice != null) { Destroy(voice); } var microphone = GameObject.Find("[FG]Microphone"); if (microphone != null) { if (CustomMicrophone.IsRecording(CustomMicrophone.devices[0])) { CustomMicrophone.End(CustomMicrophone.devices[0]); } Destroy(microphone); } // request microphone permissions at the start of the menu if (!CustomMicrophone.HasMicrophonePermission()) { CustomMicrophone.RequestMicrophonePermission(); } if (!CustomMicrophone.HasConnectedMicrophoneDevices()) { CustomMicrophone.RefreshMicrophoneDevices(); } //Debug.Log(CustomMicrophone.devices.Length + " microphone devices found"); // destroys game tracker from previous game if (GameObject.FindGameObjectWithTag("GameTracker") != null) { Destroy(GameObject.FindGameObjectWithTag("GameTracker")); } // disconnects the player if they were already connected if (PhotonNetwork.IsConnected) { PhotonNetwork.Disconnect(); Cursor.lockState = CursorLockMode.None; Cursor.visible = true; } PhotonNetwork.ConnectUsingSettings(); //Debug.Log(PhotonNetwork.PhotonServerSettings); }
/// <summary> /// Requests microphone perission and refreshes list of microphones if WebGL platform /// </summary> public void RefreshMicrophones() { CustomMicrophone.RequestMicrophonePermission(); }
private void RequestPermission() { CustomMicrophone.RequestMicrophonePermission(); }