void playVoice() { VoiceMgr vmr = VoiceMgr.GetInstance(); RoomMgr rm = RoomMgr.GetInstance(); if (_playingSeat < 0 && mVoiceQueue.Count > 0) { ChatItem vm = mVoiceQueue.Dequeue(); string msg = vm.voice.msg; string file = vm.path; int si = rm.getSeatIndexByID(vm.sender); int local = rm.getLocalIndex(si); _playingSeat = local; vmr.writeVoice(file, msg); vmr.play(file); if (playing != null) { playing.SetActive(false); playing = null; } playing = vm.vobj; if (playing != null) { playing.SetActive(true); } _lastPlayTime = PUtils.getMilliSeconds() + vm.voice.time; } }
public void onPress() { bar.width = 0; notice.text = "请按住说话"; voice.SetActive(true); lastTouchTime = PUtils.getMilliSeconds(); Debug.Log("onPress"); VoiceMgr.GetInstance().prepare("record.amr"); }
static int _m_getMilliSeconds_xlua_st_(RealStatePtr L) { try { { long gen_ret = PUtils.getMilliSeconds( ); LuaAPI.lua_pushint64(L, gen_ret); return(1); } } catch (System.Exception gen_e) { return(LuaAPI.luaL_error(L, "c# exception:" + gen_e)); } }
void Update() { if (lastTouchTime > 0) { long time = PUtils.getMilliSeconds() - lastTouchTime; if (time >= MAXTIME) { onVoiceOK(); } else { bar.width = (int)(((float)time / MAXTIME) * oldWidth); } } }
void Update() { long now = PUtils.getMilliSeconds(); if (_lastPlayTime != 0) { if (now > _lastPlayTime + 200) { onPlayerOver(); _lastPlayTime = 0; } } else { playVoice(); } }
public void onRelease() { if (lastTouchTime == 0) { return; } if (PUtils.getMilliSeconds() - lastTouchTime < 1000) { VoiceMgr.GetInstance().cancel(); voice.SetActive(true); bar.width = 0; notice.text = "录制时间太短"; voice.SetActive(false); } else { onVoiceOK(); } lastTouchTime = 0; }
void onVoiceOK() { VoiceMgr vm = VoiceMgr.GetInstance(); if (lastTouchTime > 0) { vm.release(); long time = PUtils.getMilliSeconds() - lastTouchTime; string msg = vm.getVoiceData("record.amr"); if (msg != null && msg.Length > 0) { JsonObject ob = new JsonObject(); ob ["msg"] = msg; ob ["time"] = time; NetMgr.GetInstance().send("voice_msg", ob); } } voice.SetActive(false); }