public override void OnInspectorGUI() { VoiceChatRecorder recorder = target as VoiceChatRecorder; if (Application.isPlaying && Network.isClient) { EditorGUILayout.LabelField("Available Devices", EditorStyles.boldLabel); foreach (string device in recorder.AvailableDevices) { EditorGUILayout.LabelField(device); } EditorGUILayout.LabelField("Selected Device", EditorStyles.boldLabel); int index = Mathf.Clamp(Array.IndexOf(recorder.AvailableDevices, recorder.Device), 0, Int32.MaxValue) + 1; string[] devices = new string[1] { "Default" }.Concat(recorder.AvailableDevices).ToArray(); index = EditorGUILayout.Popup(index, devices); if (index != 0) { recorder.Device = devices[index]; } else { recorder.Device = null; } if (recorder.IsRecording) { if (GUILayout.Button("Stop Recording")) { recorder.StopRecording(); } } else { if (GUILayout.Button("Start Recording")) { recorder.StartRecording(); } } } else { DrawDefaultInspector(); } }
//开始录音 public void StartRecording() { #if UNITY_IOS if (!VoiceChatPlayer.VoiceAuth()) { return; } #endif Stop(); if (recorder == null) { return; } recorder.StartRecording(); recorder.setTransmitToggled(true); }
// Use this for initialization void Start() { // Get Components for Pointers recorder = GetComponent<VoiceChatRecorder> (); // Presumes that the first device availiable is the best recorder.Device = recorder.AvailableDevices [0]; //TODO: Get NetworkId from DarkRift before recording recorder.StartRecording(); //TODO: LIST // 1. Set VoiceChatRecorder.Instance.NetworkId to a unique number on each client // 2. Subscribe to the VoiceChatRecorder.Instance.NewSample event // 3. When the NewSample events get triggered, send the VoiceChatPacket data to all other clients. // 4. On the client read the data back, and make sure you have one instance of the Network/Resources/VoiceChat_Player prefab, grab the VoiceChatPlayer script and call OnNewSample(packet) on it. }
private IEnumerator InitMicrophone() { yield return(Application.RequestUserAuthorization(UserAuthorization.Microphone)); print("Microphones " + Microphone.devices.Length); if (Microphone.devices.Length > 0) { VoiceChatRecorder v = VoiceChatRecorder.Instance; v.enabled = true; v.NetworkId = PhotonNetwork.player.ID; v.Device = v.AvailableDevices[0]; v.StartRecording(); v.NewSample -= VoiceChat; v.NewSample += VoiceChat; } yield return(null); }
private IEnumerator InitMicrophone() { if (_Loader.dm && !Application.HasUserAuthorization(UserAuthorization.Microphone)) { ShowWindowNoBack(_Game.MenuWindow); } yield return(Application.RequestUserAuthorization(UserAuthorization.Microphone)); Debug.LogWarning("Microphones " + Microphone.devices.Length); if (Microphone.devices.Length > 0) { VoiceChatRecorder v = VoiceChatRecorder.Instance; v.enabled = true; v.NetworkId = PhotonNetwork.player.ID; v.Device = v.AvailableDevices[0]; v.StartRecording(); v.NewSample -= VoiceChat; v.NewSample += VoiceChat; } yield return(null); }