void OnPlayAudio(int audioIndex) { if (audioCache.ContainsKey(audioIndex)) { Main.Ins.Sound.Stop(); Main.Ins.Music.Stop(); AudioClip au = AudioClip.Create("talk", audioCache[audioIndex].Length, 1, MicChat.samplingRate, false); MicChat.SetData(au, audioCache[audioIndex]); Main.Ins.SoundManager.PlayClip(au); } }
void Record() { if (recording) { Main.Ins.SoundManager.Mute(false); int length = 0; clip = null; MicChat.EndRecording(out length, out clip); recording = false; CountDown.SetActive(false); audioData = clip.GetData(); if (audioData != null && audioData.Length != 0) { Listen.gameObject.SetActive(true); } Control("Record", WndObject).GetComponentInChildren <Text>().text = "录音"; return; } else { //把音效和音乐全部静止 Main.Ins.SoundManager.Mute(true); recording = MicChat.TryStartRecording(); if (recording) { Control("Record", WndObject).GetComponentInChildren <Text>().text = "停止"; if (Listen == null) { GameObject objListen = Control("Listen", WndObject); Listen = objListen.GetComponent <Button>(); objListen.SetActive(false); } else { Listen.gameObject.SetActive(false); } CountDown.SetActive(true); RecordTick = 0; nSeconds = Mathf.CeilToInt(MicChat.maxRecordTime - RecordTick); CountDown.GetComponentInChildren <Text>().text = string.Format("录制中{0}", nSeconds); } } }