private void OnPrassVoice(GameObject sender, bool isPrass) { #if UNITY_ANDROID if (!XyskAndroidAPI.hasMicrophoneAuth() && isPrass) { PopText.Instance.Show(LanguageManager.instance.GetValue("microphoneforbidden"), PopText.WarningType.WT_Warning); return; } #elif UNITY_IOS if (!XyskIOSAPI.HasMicrophoneAuth() && isPrass) { PopText.Instance.Show(LanguageManager.instance.GetValue("microphoneforbidden"), PopText.WarningType.WT_Warning); return; } #endif if (Microphone.devices.Length == 0) { ClientLog.Instance.Log("No Record Device!"); return; } if (isPrass) { isCanel = false; ischaoshi = false; PrassTime = Time.realtimeSinceStartup; istargetPrass = true; ChatSystem.StartRecord(); yuyinTips.SetActive(true); } else { istargetPrass = false; yuyinTips.SetActive(false); if (ischaoshi) { return; } float tm = Time.realtimeSinceStartup - PrassTime; ChatSystem.StopRecord(); if (tm < 1) { PopText.Instance.Show(LanguageManager.instance.GetValue("chatVeTime")); } else { if (isCanel) { return; } if (ChatSystem.AsyncGetCallBack == null) { ChatSystem.AsyncGetCallBack = delegate(byte[] datas) { audioChat_ = new COM_Chat(); audioChat_.audio_ = datas; audioChat_.isAudio_ = true; audioChat_.audioTime_ = (int)tm; //int le = Mathf.RoundToInt(ChatSystem.GetClipLength(audioChat_.audio_)); ChatSystem.SendToServer(_SendChatKind, "", "", audioChat_.audio_, audioChat_.audioTime_); ClientLog.Instance.Log("audioChat_.audio_=====" + audioChat_.audio_.Length); audioChat_ = null; }; ChatSystem.AsyncGet(); } } } }
private void OnPrassVoice(GameObject sender, bool isPrass) { #if UNITY_ANDROID if (!XyskAndroidAPI.hasMicrophoneAuth()) { PopText.Instance.Show(LanguageManager.instance.GetValue("microphoneforbidden"), PopText.WarningType.WT_Warning); return; } #elif UNITY_IOS if (!XyskIOSAPI.HasMicrophoneAuth() && isPrass) { PopText.Instance.Show(LanguageManager.instance.GetValue("microphoneforbidden"), PopText.WarningType.WT_Warning); return; } #endif if (Microphone.devices.Length == 0) { ClientLog.Instance.Log("No Record Device!"); return; } if (isPrass) { isCanel = false; ischaoshi = false; PrassTime = Time.realtimeSinceStartup; istargetPrass = true; ChatSystem.StartRecord(); yuyinTips.SetActive(true); } else { istargetPrass = false; yuyinTips.SetActive(false); chat_com = new COM_Chat(); if (ischaoshi) { return; } float tm = Time.realtimeSinceStartup - PrassTime; if (tm < 1) { PopText.Instance.Show(LanguageManager.instance.GetValue("chatVeTime")); } else { if (isCanel) { return; } ChatSystem.StopRecord(); if (ChatSystem.AsyncGetCallBack == null) { ChatSystem.AsyncGetCallBack = delegate(byte[] datas) { chat_com.audio_ = datas; NetConnection.Instance.queryOnlinePlayerbyName(_selectFriend.name_); }; ChatSystem.AsyncGet(); } //ChatSystem.GetClip(ref chat_com.audio_); //NetConnection.Instance.queryOnlinePlayerbyName (_selectFriend.name_); //ChatSystem.SendToServer(_SendChatKind,"","",chat_com.audio_); } } }