public void PlayVoice(string urlLocal) { AudioListener.volume = 0f; //找到对应位置的语音动画播放 PlayerPlayingPanelData pppd = GameData.Instance.PlayerPlayingPanelData; // Debug.LogWarning("玩家index:" + (pppd.GetOtherPlayerShowPos(pppd.GetOtherPlayerPos(voices[0].iUserId)) - 1)); int index = pppd.GetOtherPlayerShowPos(pppd.GetOtherPlayerPos(voices[0].iUserId)) - 1; UIMainView.Instance.PlayerPlayingPanel._playingHead[index].GetChild(4).GetComponent <Animator>().SetBool("isPlayOthers", true); //Debug.LogWarning("动画没问题"); string ext = DateTime.Now.ToFileTime().ToString(); if (VoiceFlag == 1) { string[] pathSplit = voices[0].szRecordUrlPath.Split('/'); string localFilePath = isExistGvoiceFile(MahjongLobby_AH.SDKManager.DataPath) + pathSplit[pathSplit.Length - 1]; int downLoadErr = m_voiceengine.DownloadRecordedFile(ByteArrayToHexString(voices[0].id), localFilePath, 6000); ShortTalkData std = GameData.Instance.ShortTalkData; if (!std._DownLoadFilePath.ContainsKey(voices[0].szRecordUrlPath)) { std._DownLoadFilePath.Add(voices[0].szRecordUrlPath, localFilePath); Debug.LogWarning("下载地址1:" + voices[0].szRecordUrlPath); } Debug.LogWarning("下载地址2:" + localFilePath); m_voiceengine.OnPlayRecordFilComplete += (code, filePath) => { if (code != IGCloudVoice.GCloudVoiceCompleteCode.GV_ON_PLAYFILE_DONE) { Debug.Log("OnPlayRecordFilComplete error" + code); } else { Chenggong = true; StartCoroutine(CompeletPlay()); } }; ErroOccur(downLoadErr, () => { StartCoroutine(CompeletPlay()); }); } else { YunVaImSDK.instance.RecordStartPlayRequest(urlLocal, voices[0].szRecordUrlPath, ext, (data2) => { Debug.LogWarning("data2.result:" + data2.result + "Chenggong:" + Chenggong); if (data2.result == 0) { Chenggong = true; StartCoroutine(CompeletPlay()); } else { VoiceInit(); // StartCoroutine(CompeletPlay()); //Debug.LogWarning("播放失败");//关静音 Debug.LogWarning(voices[0].szRecordUrlPath); MahjongCommonMethod.Instance.ShowRemindFrame("语音播放失败", true); } }); } }
IEnumerator CompeletPlay(float time = -1) { yield return(new WaitForSeconds(0)); if (voices.Count > 0) { PlayerPlayingPanelData pppd = GameData.Instance.PlayerPlayingPanelData; int index_pH = pppd.GetOtherPlayerShowPos(pppd.GetOtherPlayerPos(voices[0].iUserId)) - 1; Debug.LogWarning("播放完成" + voices[0].iUserId + "index_pH:" + index_pH); if (index_pH >= 0 && index_pH <= 3) { UIMainView.Instance.PlayerPlayingPanel._playingHead[index_pH].GetChild(4).GetComponent <Animator>().SetBool("isPlayOthers", false); } isPlayingState = false;//关闭播放状态 voices.RemoveAt(0); } AudioListener.volume = 1; if (time > 0) { StopCoroutine(DealNoReasult(time)); } }
/// <summary> /// 点击继续按钮 /// </summary> void HandleBtnNextRound(int status) { PlayerPlayingPanelData pppd = GameData.Instance.PlayerPlayingPanelData; GameResultPanelData grpd = GameData.Instance.GameResultPanelData; //如果是手动点击继续,自动解除托管 if (status == 1) { if (pppd.iPlayerHostStatus > 0) { GameData.Instance.GameResultPanelData.iHandClick = 1; NetMsg.ClientCancleAutoStatusReq msg = new NetMsg.ClientCancleAutoStatusReq(); msg.iUserId = GameData.Instance.PlayerNodeDef.iUserId; msg.iSeatNum = (byte)pppd.bySeatNum; Network.NetworkMgr.Instance.GameServer.SendClientCancleAutoStatusReq(msg); } } else { GameData.Instance.GameResultPanelData.iHandClick = 2; } //如果玩家是托管,这个时候检测解散信息 if (pppd.iDissolveFlag == 1) { pppd.iDissolveFlag = 0; NetMsg.ClientDismissRoomRes msg = pppd.DismissRoomRes; //显示解散界面 int seatNum = pppd.GetOtherPlayerPos(msg.iUserId); //显示玩家发起解散房间 if (msg.cType == 1) { if (pppd.isBeginGame || pppd.iMethodId == 11) { //显示界面 UIMainView.Instance.PlayerPlayingPanel.DissolvePanel.SetActive(true); UIMainView.Instance.PlayerPlayingPanel.DissolvePanel.transform.localPosition = Vector3.zero; UIMainView.Instance.PlayerPlayingPanel.DissolvePanel.transform.localScale = Vector3.one; if (pppd.isBeginGame || pppd.isWatingPlayerDownOrUp) { //更新界面 UIMainView.Instance.PlayerPlayingPanel.DissolvePanel.GetComponent <DissvloeNoticePanel>().iseatNum = seatNum; UIMainView.Instance.PlayerPlayingPanel.DissolvePanel.GetComponent <DissvloeNoticePanel>().ShowAllPlayerMessage(); } } } else if (msg.cType == 3) { UIMainView.Instance.PlayerPlayingPanel.DissolvePanel.SetActive(false); System.Text.StringBuilder str = new System.Text.StringBuilder(); str.Append("由于玩家【"); str.Append(pppd.usersInfo[seatNum].szNickname); str.Append("】拒绝,房间解散失败,继续游戏"); UIMgr.GetInstance().GetUIMessageView().Show(str.ToString(), Ok); } } //判断玩家是解散结束还是正常结束 if (grpd.HandDissolve == 0 && !grpd.isEndGame) { if (!pppd.isAllAutoStatus && pppd.iDissolveStatus != 1) { //发送准备请求 NetMsg.ClientReadyReq msg = new NetMsg.ClientReadyReq(); msg.iUserId = GameData.Instance.PlayerPlayingPanelData.iUserId; Debug.Log("点击继续按钮,发送准备请求"); Network.NetworkMgr.Instance.GameServer.SendReadyReq(msg); } GameData.Instance.GameResultPanelData.isPanelShow = false; if (pppd.isBeginGame) { UIMainView.Instance.PlayerPlayingPanel.InitPanel(); } } //如果玩家是解散结束的 else { //关闭玩家的单局结算界面 grpd.isShowRoundGameResult = false; //显示总的结算数据 grpd.isShowRoomGameResult = true; UIMainView.Instance.GameResultPanel.SpwanAllGameResult(); UpdateShow(); } SystemMgr.Instance.GameResultSystem.UpdateShow(); }
public void StopPlayingVoice() { MahjongCommonMethod mc = MahjongCommonMethod.Instance;//开静音 PlayerPlayingPanelData pppd = GameData.Instance.PlayerPlayingPanelData; if (VoiceFlag == 1) { int err = m_voiceengine.StopPlayFile(); if (err != 0) { ErroOccur(err, null); } } else { YunVaImSDK.instance.RecordStopPlayRequest(); } UIMainView.Instance.PlayerPlayingPanel._playingHead[pppd.GetOtherPlayerShowPos(pppd.GetOtherPlayerPos(voices[0].iUserId)) - 1].GetChild(4).GetComponent <Animator>().SetBool("isPlayOthers", false); isPlayingState = false; //关闭播放状态 // mc.isMusicShut = false; if (voices.Count > 0) { voices.RemoveAt(0); } // SystemMgr.Instance.BgmSystem.UpdateVolume(); }