using System; using System.Collections.Generic; using System.IO; using System.Text; using KKSG; using UnityEngine; using XMainClient.UI; using XMainClient.UI.UICommon; using XUpdater; using XUtliPoolLib; namespace XMainClient { internal class XChatIFlyMgr : XSingleton { public bool IsAutoPlayEnable { get { return this._enable_auto_play; } } public IXIFlyMgr IFLYMGR { get { return this._ifly_mgr; } } public Dictionary LocalAudio { get { return this._local_audio; } } public List AutoPlayAudioList { get { bool flag = this.m_lAutoPlayAudioList == null; if (flag) { this.m_lAutoPlayAudioList = new List(); } return this.m_lAutoPlayAudioList; } set { this.m_lAutoPlayAudioList = value; } } private static readonly float MIN_RECORD_LENGTH = 0.3f; private static readonly float AUDIO_TIME_OUT = 10f; private static int CLEAR_AUDIO_COUNT = 20; private IXIFlyMgr _ifly_mgr = null; private string audiotxt = ""; private VoiceUsage _usage = VoiceUsage.CHAT; private string _upload_file = ""; private float _record_start = 0f; private float _record_length = 0f; private string cachePath = ""; private ChatChannelType _channel_type = ChatChannelType.DEFAULT; private ChatInfo _download_audio = null; private uint _auto_play_timer = 0u; private uint _record_timer = 0u; private uint _translate_timer = 0u; private uint _prepare_record_time = 0u; private bool _is_recording = false; private bool _enable_auto_play = false; private EndRecordCallBack _callback = null; private float _try_trans_start_time = 0f; private uint _txt_length_limit; private uint _windows_audio_token; private bool[] _auto_play_enable_channel = new bool[XFastEnumIntEqualityComparer.ToInt(ChatChannelType.ChannelNum)]; private List m_lAutoPlayAudioList; private Dictionary _local_audio = new Dictionary(); private List _auto_play_list = new List(); private int MAX_DELETE_CNT = 100; private UpLoadAudioRes lastAudoRes; private static ulong lastFileID = 0UL; public XChatIFlyMgr() { for (int i = 0; i < XFastEnumIntEqualityComparer.ToInt(ChatChannelType.ChannelNum); i++) { bool flag = i == XFastEnumIntEqualityComparer.ToInt(ChatChannelType.Group); if (flag) { this._auto_play_enable_channel[i] = false; } else { this._auto_play_enable_channel[i] = true; } } } public void InitFlyMgr() { bool flag = this._ifly_mgr == null; if (flag) { this._ifly_mgr = (XUpdater.XUpdater.XGameRoot.GetComponent("XIFlyMgr") as IXIFlyMgr); } bool flag2 = this._ifly_mgr != null; if (flag2) { this._ifly_mgr.SetCallback(new Action(this.RecoganizeCallback)); this._ifly_mgr.SetVoiceCallback(new Action(this.VoiceVolumeCallback)); } XChatDocument specificDocument = XDocuments.GetSpecificDocument(XChatDocument.uuID); this._txt_length_limit = specificDocument.GetRawData(ChatChannelType.World).length / 3u; } public bool NeedClear() { try { string audioCachePath = this.GetAudioCachePath(); bool flag = Directory.Exists(audioCachePath); if (flag) { DirectoryInfo directoryInfo = new DirectoryInfo(audioCachePath); FileInfo[] files = directoryInfo.GetFiles(); bool flag2 = files != null; if (flag2) { bool flag3 = files.Length > XChatIFlyMgr.CLEAR_AUDIO_COUNT; if (flag3) { return true; } } } string persistentDataPath = Application.persistentDataPath; bool flag4 = Directory.Exists(persistentDataPath); if (flag4) { DirectoryInfo directoryInfo2 = new DirectoryInfo(persistentDataPath); FileInfo[] files2 = directoryInfo2.GetFiles(); bool flag5 = files2 != null; if (flag5) { bool flag6 = files2.Length > XChatIFlyMgr.CLEAR_AUDIO_COUNT; if (flag6) { return true; } } } } catch { } return false; } public void ClearAudioCache() { string audioCachePath = this.GetAudioCachePath(); bool flag = Directory.Exists(audioCachePath); if (flag) { DirectoryInfo directoryInfo = new DirectoryInfo(audioCachePath); FileInfo[] files = directoryInfo.GetFiles(); bool flag2 = files != null; if (flag2) { int num = Mathf.Min(this.MAX_DELETE_CNT, files.Length); for (int i = 0; i < num; i++) { string extension = files[i].Extension; bool flag3 = !extension.Equals(".mp3") && !extension.Equals(".sound"); if (!flag3) { XSingleton.singleton.AddLog("delete: ", files[i].Name, " ext: ", extension, null, null, XDebugColor.XDebug_None); try { this.RemoveLocalAudio(files[i].Name); File.Delete(files[i].FullName); } catch { XSingleton.singleton.AddErrorLog("Delete file error, ", files[i].FullName, null, null, null, null); } } } } } string persistentDataPath = Application.persistentDataPath; bool flag4 = Directory.Exists(persistentDataPath); if (flag4) { DirectoryInfo directoryInfo2 = new DirectoryInfo(persistentDataPath); FileInfo[] files2 = directoryInfo2.GetFiles(); bool flag5 = files2 != null; if (flag5) { int num2 = Mathf.Min(this.MAX_DELETE_CNT, files2.Length); for (int j = 0; j < num2; j++) { string extension2 = files2[j].Extension; bool flag6 = !extension2.Equals(".mp3") && !extension2.Equals(".sound"); if (!flag6) { XSingleton.singleton.AddLog("delete: ", files2[j].Name, " ext: ", extension2, null, null, XDebugColor.XDebug_None); try { this.RemoveLocalAudio(files2[j].Name); File.Delete(files2[j].FullName); } catch { XSingleton.singleton.AddErrorLog("Delete apollo file error, ", files2[j].FullName, null, null, null, null); } } } } } } private void RemoveLocalAudio(string name) { ulong key = 0UL; ulong.TryParse(name, out key); bool flag = this._local_audio.ContainsKey(key); if (flag) { this._local_audio.Remove(key); } } public void RemoveOldRecordFile() { string audioCachePath = this.GetAudioCachePath(); bool flag = Directory.Exists(audioCachePath); if (flag) { DirectoryInfo directoryInfo = new DirectoryInfo(audioCachePath); FileInfo[] files = directoryInfo.GetFiles(); bool flag2 = files != null; if (flag2) { for (int i = 0; i < files.Length; i++) { string a = files[i].Name.Substring(files[i].Name.LastIndexOf(".") + 1); bool flag3 = a != "pcm"; if (!flag3) { try { files[i].Delete(); } catch { XSingleton.singleton.AddLog("Delete file failed: ", files[i].Name, null, null, null, null, XDebugColor.XDebug_None); } break; } } } } } public void GenerateAudioFiles(int num) { string text = this.GetAudioCachePath(); bool flag = Directory.Exists(text); if (flag) { DirectoryInfo directoryInfo = new DirectoryInfo(text); FileInfo[] files = directoryInfo.GetFiles(); bool flag2 = files != null; if (flag2) { for (int i = 0; i < files.Length; i++) { string a = files[i].Name.Substring(files[i].Name.LastIndexOf(".") + 1); bool flag3 = a == "mp3"; if (flag3) { for (int j = 0; j < num; j++) { string text2 = text + "/" + j.ToString() + ".mp3"; bool flag4 = !File.Exists(text2); if (flag4) { File.Copy(files[i].FullName, text2); } } break; } } } } text = Application.persistentDataPath; bool flag5 = Directory.Exists(text); if (flag5) { DirectoryInfo directoryInfo2 = new DirectoryInfo(text); FileInfo[] files2 = directoryInfo2.GetFiles(); bool flag6 = files2 != null; if (flag6) { for (int k = 0; k < files2.Length; k++) { string a2 = files2[k].Name.Substring(files2[k].Name.LastIndexOf(".") + 1); bool flag7 = a2 == "sound"; if (flag7) { for (int l = 0; l < num; l++) { string text3 = text + "/" + l.ToString() + ".sound"; bool flag8 = !File.Exists(text3); if (flag8) { File.Copy(files2[k].FullName, text3); } } break; } } } } } public bool IsIFlyListening() { bool flag = this._ifly_mgr != null; return flag && this._ifly_mgr.IsIFlyListening(); } public bool IsRecording() { return this._is_recording; } public void EnableAutoPlay(bool enable) { XRadioDocument specificDocument = XDocuments.GetSpecificDocument(XRadioDocument.uuID); bool flag = specificDocument != null && specificDocument.roomState == XRadioDocument.BigRoomState.InRoom && enable; if (!flag) { XSingleton.singleton.AddLog("Enable auto play: ", enable.ToString(), null, null, null, null, XDebugColor.XDebug_None); this._enable_auto_play = enable; } } public void SetBackMusicOn(bool on) { XAudioOperationArgs @event = XEventPool.GetEvent(); @event.IsAudioOn = on; @event.Firer = XSingleton.singleton.Doc; XSingleton.singleton.FireEvent(@event); } public void SetChannelAutoPlay(ChatChannelType type, bool auto) { bool flag = XFastEnumIntEqualityComparer.ToInt(type) >= this._auto_play_enable_channel.Length; if (!flag) { this._auto_play_enable_channel[XFastEnumIntEqualityComparer.ToInt(type)] = auto; } } public bool IsChannelAutoPlayEnable(ChatChannelType type) { bool flag = XFastEnumIntEqualityComparer.ToInt(type) >= this._auto_play_enable_channel.Length; return !flag && this._auto_play_enable_channel[XFastEnumIntEqualityComparer.ToInt(type)]; } private void setRadioOn(bool on) { XRadioDocument specificDocument = XDocuments.GetSpecificDocument(XRadioDocument.uuID); bool flag = specificDocument != null; if (flag) { specificDocument.MuteSounds(!on); } } public void StartRecord(VoiceUsage usage = VoiceUsage.CHAT, EndRecordCallBack callback = null) { bool flag = this._ifly_mgr == null || !this._ifly_mgr.IsInited(); if (flag) { XSingleton.singleton.ShowSystemTip(XSingleton.singleton.GetString("CHAT_INIT_FAILED"), "fece00"); } else { bool isBroadcast = DlgBase.singleton.isBroadcast; if (isBroadcast) { XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("FM_VOICE_BROAD"), "fece00"); } else { XRadioDocument specificDocument = XDocuments.GetSpecificDocument(XRadioDocument.uuID); bool flag2 = specificDocument.isHosting(); if (flag2) { XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("FM_VOICE_RADIO"), "fece00"); } else { this.StopAutoPlay(); this._ifly_mgr.Cancel(); this.SetBackMusicOn(false); this.setRadioOn(false); this.RemoveOldRecordFile(); XSingleton.singleton.KillTimer(this._translate_timer); this._translate_timer = 0u; DlgBase.singleton.SetVisible(true, true); this._usage = usage; this._callback = callback; XSingleton.singleton.AddLog("Record StartTime: ", Time.time.ToString(), null, null, null, null, XDebugColor.XDebug_None); RuntimePlatform platform = Application.platform; if ((int)platform != 8 && (int)platform != 11) { this.audiotxt = DateTime.Now.ToString(); this._windows_audio_token = XSingleton.singleton.SetTimer(0.2f, new XTimerMgr.ElapsedEventHandler(this.RefreshWindowsVoice), null); } else { this.audiotxt = ""; } bool flag3 = usage == VoiceUsage.CHAT; if (flag3) { this._prepare_record_time = XSingleton.singleton.SetTimer(0.15f, new XTimerMgr.ElapsedEventHandler(this.DoStartRecord), null); } else { this.DoStartRecord(null); } } } } } private void DoStartRecord(object obj) { this._is_recording = true; this._record_start = Time.realtimeSinceStartup; bool flag = this._ifly_mgr != null; if (flag) { try { this._ifly_mgr.StartRecord(); } catch { XSingleton.singleton.AddErrorLog("IFly Start record error", null, null, null, null, null); } } this._record_timer = XSingleton.singleton.SetTimer(10.5f, new XTimerMgr.ElapsedEventHandler(this.RecordTimeOut), null); } private void RefreshWindowsVoice(object obj) { DlgBase.singleton.OnSetVolume((uint)XSingleton.singleton.RandomInt(0, 7)); this._windows_audio_token = XSingleton.singleton.SetTimer(0.2f, new XTimerMgr.ElapsedEventHandler(this.RefreshWindowsVoice), null); } public void RecoganizeCallback(string txt) { bool flag = (long)this.audiotxt.Length <= (long)((ulong)this._txt_length_limit); if (flag) { bool flag2 = (long)(this.audiotxt.Length + txt.Length) <= (long)((ulong)this._txt_length_limit); if (flag2) { this.audiotxt += txt; } else { bool flag3 = this._txt_length_limit - (uint)(this.audiotxt.Length + 1) > 0u; if (flag3) { this.audiotxt += txt.Substring(0, (int)(this._txt_length_limit - (uint)(this.audiotxt.Length + 1))); } } } } public void VoiceVolumeCallback(string volume) { uint num = 0u; uint.TryParse(volume, out num); DlgBase.singleton.OnSetVolume((num * 7u + 3u) / 25u); } public void StopRecord(bool cancel) { bool flag = this._ifly_mgr == null || !this._ifly_mgr.IsInited(); if (!flag) { DlgBase.singleton.SetVisible(false, true); XSingleton.singleton.KillTimer(this._windows_audio_token); bool flag2 = this._prepare_record_time > 0u; if (flag2) { XSingleton.singleton.KillTimer(this._prepare_record_time); this._prepare_record_time = 0u; } this.SetBackMusicOn(true); this.setRadioOn(true); bool flag3 = !this._is_recording; if (!flag3) { bool flag4 = this._record_timer > 0u; if (flag4) { XSingleton.singleton.KillTimer(this._record_timer); this._record_timer = 0u; } bool flag5 = !cancel; if (flag5) { this._ifly_mgr.StopRecord(); this._record_length = Time.realtimeSinceStartup - this._record_start; this._record_length = ((this._record_length > 10f) ? 10f : this._record_length); XSingleton.singleton.AddLog("Record StopTime: ", Time.time.ToString(), null, null, null, null, XDebugColor.XDebug_None); bool flag6 = this._record_length <= XChatIFlyMgr.MIN_RECORD_LENGTH; if (flag6) { XSingleton.singleton.ShowSystemTip(XStringDefineProxy.GetString("CHAT_RECORD_TOO_SHORT"), "fece00"); } else { string param = string.Format("{0:D2}{1:D2}{2:D2}", DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second); this._translate_timer = XSingleton.singleton.SetTimer(0.1f, new XTimerMgr.ElapsedEventHandler(this.DelayTransMp3), param); this._try_trans_start_time = Time.time; } } this._is_recording = false; } } } private void RecordTimeOut(object obj) { bool flag = !this._is_recording; if (!flag) { this.StopRecord(false); bool flag2 = this._callback != null; if (flag2) { this._callback(); } } } public void DelayTransMp3(object obj) { string text = obj as string; bool flag = Time.time - this._try_trans_start_time >= 0.3f; if (flag) { this.StartTransMp3(text); } else { bool flag2 = this._ifly_mgr != null && (this._ifly_mgr.IsIFlyListening() || !this._ifly_mgr.IsRecordFileExist()); if (flag2) { this._translate_timer = XSingleton.singleton.SetTimer(0.1f, new XTimerMgr.ElapsedEventHandler(this.DelayTransMp3), text); } else { this.StartTransMp3(text); } } } public void StartTransMp3(string destFileName) { string filePath = ""; RuntimePlatform platform = Application.platform; if ((int)platform != 8 && (int)platform != 11) { filePath = "Assets/Editor/Mp3Sample/sample.mp3"; } else { bool flag = this._ifly_mgr != null; if (flag) { bool flag2 = !this._ifly_mgr.IsRecordFileExist(); if (flag2) { XSingleton.singleton.AddErrorLog("Record busy, can't record", null, null, null, null, null); return; } filePath = this._ifly_mgr.StartTransMp3(destFileName); } } this.StartUpLoadMp3(filePath); } public void StartUpLoadMp3(string filePath) { XSingleton.singleton.AddLog("Will start upload mp3, txt:", this.audiotxt, null, null, null, null, XDebugColor.XDebug_None); RpcC2T_UpLoadAudioToGate rpcC2T_UpLoadAudioToGate = new RpcC2T_UpLoadAudioToGate(); rpcC2T_UpLoadAudioToGate.oArg.audio = File.ReadAllBytes(filePath); rpcC2T_UpLoadAudioToGate.oArg.text = Encoding.UTF8.GetBytes(this.audiotxt); rpcC2T_UpLoadAudioToGate.oArg.srctype = 0u; this._upload_file = filePath; XSingleton.singleton.AddLog("The audio length: ", rpcC2T_UpLoadAudioToGate.oArg.audio.Length.ToString(), null, null, null, null, XDebugColor.XDebug_None); XSingleton.singleton.Send(rpcC2T_UpLoadAudioToGate); } public void UpLoadMp3Res(UpLoadAudioRes res) { uint num = (uint)(this._record_length * 1000f) + 1u; XSingleton.singleton.AddLog("Will upload res mp3, usage: ", null, null, null, null, null, XDebugColor.XDebug_None); bool flag = this._usage == VoiceUsage.CHAT; if (flag) { this._local_audio[res.audiodownuid] = this._upload_file; this.lastAudoRes = res; bool flag2 = DlgBase.singleton.CheckWorldSendMsg(true, null, ChatChannelType.DEFAULT); if (flag2) { bool flag3 = num >= 9000u && this.audiotxt.Length <= (int)(num / 2000u); if (!flag3) { XSingleton.singleton.AddLog("Will Do send world chat", null, null, null, null, null, XDebugColor.XDebug_None); DlgBase.singleton.SendVoiceChat(this.audiotxt, DlgBase.singleton.activeChannelType, res.audiodownuid, num * 1f); } } } else { bool flag4 = this._usage == VoiceUsage.ANSWER; if (flag4) { XVoiceQADocument specificDocument = XDocuments.GetSpecificDocument(XVoiceQADocument.uuID); XSingleton.singleton.AddLog("Will Do send answer chat", null, null, null, null, null, XDebugColor.XDebug_None); specificDocument.SendAnswer(this.audiotxt, res.audiodownuid, num); } else { bool flag5 = this._usage == VoiceUsage.FLOWER_REPLY; if (flag5) { this._local_audio[res.audiodownuid] = this._upload_file; this.lastAudoRes = res; DlgBase.singleton.SendVoiceChat(this.audiotxt, ChatChannelType.Friends, res.audiodownuid, num * 1f); } else { bool flag6 = this._usage == VoiceUsage.MENTORHIP; if (flag6) { this._local_audio[res.audiodownuid] = this._upload_file; this.lastAudoRes = res; } else { bool flag7 = this._usage == VoiceUsage.GUILDCOLLECT; if (flag7) { XExchangeItemDocument specificDocument2 = XDocuments.GetSpecificDocument(XExchangeItemDocument.uuID); XSingleton.singleton.AddLog("Will Do send voice chat in guild collect", null, null, null, null, null, XDebugColor.XDebug_None); specificDocument2.SendChat(this.audiotxt, res.audiodownuid, num); } } } } } } public void ResendLastWorldChat() { bool useApollo = XChatDocument.UseApollo; if (useApollo) { XSingleton.singleton.ResendLastWorldChat(); } else { uint num = (this._record_length >= 1f) ? ((uint)this._record_length) : 1u; bool flag = this.lastAudoRes != null; if (flag) { DlgBase.singleton.SendVoiceChat(this.audiotxt, DlgBase.singleton.activeChannelType, this.lastAudoRes.audiodownuid, num * 1f); } } } public void DownloadMp3(ChatInfo info) { XSingleton.singleton.AddLog("Will Download mp3", null, null, null, null, null, XDebugColor.XDebug_None); this._download_audio = info; RpcC2A_GetAudioListReq rpcC2A_GetAudioListReq = new RpcC2A_GetAudioListReq(); rpcC2A_GetAudioListReq.oArg.audioUidList.Add(info.mAudioId); XSingleton.singleton.Send(rpcC2A_GetAudioListReq); } public void DownloadMp3Res(GetAudioListRes res) { bool flag = res.dataList == null || res.dataList.Count == 0; if (flag) { XSingleton.singleton.AddLog("Download res error", null, null, null, null, null, XDebugColor.XDebug_None); this.DoStartAutoPlay(null); } else { AudioBrief audioBrief = res.dataList[0]; string text = this.GetAudioCachePath() + "/" + audioBrief.audioUid.ToString() + ".mp3"; bool flag2 = this._download_audio.mChannelId != ChatChannelType.DEFAULT; if (flag2) { text = this.GetAudioCachePath() + "/" + audioBrief.audioUid.ToString() + ".sound"; } File.WriteAllBytes(text, audioBrief.audio); this._local_audio[this._download_audio.mAudioId] = text; XSingleton.singleton.AddLog("Download OK, will start play mp3, audiotime: ", this._download_audio.mAudioTime.ToString(), null, null, null, null, XDebugColor.XDebug_None); this.StartPlayMp3(text, this._download_audio.mAudioTime, this._download_audio); this.ChatShowInfo(this._download_audio); } } public void DownLoadMp3Error() { this.DoStartAutoPlay(null); } public void StartPlayMp3(string filepath, uint audiotime, ChatInfo info) { IApolloManager xapolloManager = XSingleton.singleton.XApolloManager; xapolloManager.SetApolloMode(2); XOptionsDocument specificDocument = XDocuments.GetSpecificDocument(XOptionsDocument.uuID); int @int = XSingleton.singleton.GetInt("SetSpeakerVolume"); xapolloManager.SetMusicVolum((int)((float)@int * specificDocument.voiceVolme)); RuntimePlatform platform = Application.platform; if ((int)platform != 8 && (int)platform != 11) { XSingleton.singleton.StartPlayVoice(filepath); } else { bool flag = File.Exists(filepath); if (!flag) { XSingleton.singleton.AddLog("File not found, ", filepath, null, null, null, null, XDebugColor.XDebug_None); XSingleton.singleton.KillTimer(this._auto_play_timer); this._auto_play_timer = XSingleton.singleton.SetGlobalTimer(0.1f, new XTimerMgr.ElapsedEventHandler(this.DoStartAutoPlay), null); return; } try { XSingleton.singleton.StartPlayVoice(filepath); } catch (Exception ex) { XSingleton.singleton.AddLog("StartPlayMp3, Find play exception, ", ex.ToString(), null, null, null, null, XDebugColor.XDebug_None); } } XSingleton.singleton.KillTimer(this._auto_play_timer); bool flag2 = audiotime <= 1000u; if (flag2) { audiotime = 1000u; } this._auto_play_timer = XSingleton.singleton.SetGlobalTimer((audiotime + 10u) * 1f / 1000f, new XTimerMgr.ElapsedEventHandler(this.DoStartAutoPlay), null); XSingleton.singleton.AddLog("Will start time autoplay, time: ", audiotime.ToString(), null, null, null, null, XDebugColor.XDebug_None); this.DeleteAudio(info.mAudioId); } public void DoStartPlayChatInfo(ChatInfo info) { this.StopAutoPlay(); this.StartPlayInfo(info); } public void StartPlayInfo(ChatInfo info) { bool is_recording = this._is_recording; if (is_recording) { XSingleton.singleton.AddLog("StartPlayInfo, isrecord will return", null, null, null, null, null, XDebugColor.XDebug_None); } else { bool flag = this._local_audio.ContainsKey(info.mAudioId) && File.Exists(this._local_audio[info.mAudioId]); if (flag) { this.ChatShowInfo(info); this.StartPlayMp3(this._local_audio[info.mAudioId], info.mAudioTime, info); } else { this.DownloadMp3(info); } } } private void DeleteAudio(ulong audioid) { bool flag = XChatIFlyMgr.lastFileID == 0UL || XChatIFlyMgr.lastFileID == audioid; if (flag) { XChatIFlyMgr.lastFileID = audioid; } else { RuntimePlatform platform = Application.platform; bool flag2 = (int)platform == 8; if (flag2) { string path = string.Concat(new object[] { Application.temporaryCachePath, "/", XChatIFlyMgr.lastFileID, ".mp3" }); this.DeleteFile(path); string path2 = string.Concat(new object[] { Application.temporaryCachePath, "/", XChatIFlyMgr.lastFileID, ".sound" }); this.DeleteFile(path2); } else { string path3 = string.Concat(new object[] { Application.persistentDataPath, "/", XChatIFlyMgr.lastFileID, ".sound" }); this.DeleteFile(path3); string path4 = string.Concat(new object[] { Application.persistentDataPath, "/", XChatIFlyMgr.lastFileID, ".mp3" }); this.DeleteFile(path4); } XChatIFlyMgr.lastFileID = audioid; } } private void DeleteFile(string path) { XSingleton.singleton.AddLog("delete: ", path, null, null, null, null, XDebugColor.XDebug_None); try { bool flag = !string.IsNullOrEmpty(path); if (flag) { bool flag2 = File.Exists(path); if (flag2) { File.Delete(path); } } } catch { XSingleton.singleton.AddWarningLog("delete fail" + path, null, null, null, null, null); } } public void StartPlayAudioId(ulong audioid) { this.StartPlayInfo(new ChatInfo { mAudioId = audioid, mChannelId = ChatChannelType.DEFAULT }); } public void ClearPlayList() { this._auto_play_list.Clear(); } public void DoStartAutoPlay(object obj) { bool enable_auto_play = this._enable_auto_play; if (enable_auto_play) { this.StartAutoPlay(true, true); } else { IApolloManager xapolloManager = XSingleton.singleton.XApolloManager; xapolloManager.SetApolloMode(0); this.SetBackMusicOn(true); this.setRadioOn(true); this._auto_play_timer = 0u; } } public void StartAutoPlay(bool rank = true, bool clearTimeout = true) { if (clearTimeout) { this.ClearTimeOutInfo(); } if (rank) { this.RankAutoPlayList(); } XSingleton.singleton.AddLog("StartAutoPlay, num:", this._auto_play_list.Count.ToString(), null, null, null, null, XDebugColor.XDebug_None); bool flag = this._auto_play_list.Count == 0; if (flag) { IApolloManager xapolloManager = XSingleton.singleton.XApolloManager; xapolloManager.SetApolloMode(0); this.SetBackMusicOn(true); this.setRadioOn(true); XSingleton.singleton.AddLog("StartAutoplay setback music on", null, null, null, null, null, XDebugColor.XDebug_None); this._auto_play_timer = 0u; } else { XSingleton.singleton.AddLog("StartAutoplay setback music off", null, null, null, null, null, XDebugColor.XDebug_None); this.SetBackMusicOn(false); this.setRadioOn(false); bool flag2 = this._auto_play_list.Count > 0; if (flag2) { this.StartPlayInfo(this._auto_play_list[0]); this._auto_play_list.RemoveAt(0); } } } public void StopAutoPlay() { XSingleton.singleton.KillTimer(this._auto_play_timer); this._auto_play_timer = 0u; XSingleton.singleton.StopPlayVoice(); } public void InsertAutoPlayList(ChatInfo info, bool clearTimeOut = true) { this._auto_play_list.Insert(0, info); this.StopAutoPlay(); IApolloManager xapolloManager = XSingleton.singleton.XApolloManager; xapolloManager.SetApolloMode(2); try { this.StartAutoPlay(false, clearTimeOut); } catch (Exception ex) { XSingleton.singleton.AddLog("InsertAutoPlayList exception, ", ex.ToString(), null, null, null, null, XDebugColor.XDebug_None); } } public bool AddAutoPlayList(ChatInfo info) { bool flag = !XSingleton.singleton.IsWifiEnable() && this.IsChannelAutoPlayEnable(ChatChannelType.ZeroChannel); bool result; if (flag) { result = false; } else { bool flag2 = !this.IsChannelAutoPlayEnable(info.mChannelId); if (flag2) { result = false; } else { bool flag3 = this._channel_type != ChatChannelType.DEFAULT && info.mChannelId != this._channel_type; if (flag3) { result = false; } else { bool flag4 = XSingleton.singleton.SceneID == 100u || (XSingleton.singleton.XPlayerData.Level < 10u && DlgBase.singleton.IsVisible()); if (flag4) { result = false; } else { this._auto_play_list.Add(info); bool flag5 = this._auto_play_timer == 0u && this._enable_auto_play && !this.IsRecording(); if (flag5) { this.StartAutoPlay(true, true); } result = true; } } } } return result; } public void RankAutoPlayList() { } private void ChatShowInfo(ChatInfo info) { bool isAudioPlayed = info.isAudioPlayed; if (!isAudioPlayed) { bool flag = info.mChannelId == ChatChannelType.DEFAULT; if (!flag) { info.isAudioPlayed = true; XChatDocument specificDocument = XDocuments.GetSpecificDocument(XChatDocument.uuID); specificDocument.ReceiveChatInfo(info); } } } public void ClearTimeOutInfo() { List list = new List(); for (int i = 0; i < this._auto_play_list.Count; i++) { bool flag = (DateTime.Now - this._auto_play_list[i].mTime).TotalSeconds <= (double)XChatIFlyMgr.AUDIO_TIME_OUT; if (flag) { list.Add(this._auto_play_list[i]); } else { this.ChatShowInfo(this._auto_play_list[i]); } } this._auto_play_list = list; } public void SetAutoPlayChannel(ChatChannelType type) { bool flag = type != ChatChannelType.DEFAULT; if (flag) { List list = new List(); for (int i = 0; i < this._auto_play_list.Count; i++) { bool flag2 = this._auto_play_list[i].mChannelId == type; if (flag2) { list.Add(this._auto_play_list[i]); } else { this.ChatShowInfo(this._auto_play_list[i]); } } this._auto_play_list = list; } this._channel_type = type; } private string GetString(string path) { bool flag = string.IsNullOrEmpty(path); string result; if (flag) { result = path; } else { result = path.Replace('\\', '/'); } return result; } public string GetAudioCachePath() { bool flag = string.IsNullOrEmpty(this.cachePath); if (flag) { RuntimePlatform platform = Application.platform; if ((int)platform != 8) { if ((int)platform != 11) { this.cachePath = Application.persistentDataPath; } else { this.cachePath = Application.persistentDataPath; } } else { this.cachePath = Application.temporaryCachePath; } } return this.cachePath; } public void OnOpenWebView() { bool flag = this._ifly_mgr != null; if (flag) { this._ifly_mgr.OnOpenWebView(); } } public void OnCloseWebView() { bool flag = this._ifly_mgr != null; if (flag) { this._ifly_mgr.OnCloseWebView(); } } public void OnWebViewScreenLock(bool islock) { XSingleton.singleton.AddLog("Webview islock: ", islock.ToString(), null, null, null, null, XDebugColor.XDebug_None); bool flag = this._ifly_mgr != null; if (flag) { this._ifly_mgr.OnScreenLock(islock); } } public void OnEvalWebViewJs(string script) { bool flag = this._ifly_mgr != null; if (flag) { this._ifly_mgr.OnEvalJsScript(script); } } public void OnRefreshWebViewShow(bool show) { bool flag = this._ifly_mgr != null; if (flag) { this._ifly_mgr.RefershWebViewShow(show); } } public void RefreshWebViewConfig() { bool flag = XSingleton.singleton.Player == null; if (!flag) { int num = int.Parse(XSingleton.singleton.GetValue("HideWebView")); bool flag2 = num == 1; if (!flag2) { bool flag3 = this._ifly_mgr != null; if (flag3) { int platform = 0; XAuthorizationChannel channel = XSingleton.singleton.Channel; if (channel != XAuthorizationChannel.XAuthorization_QQ) { if (channel == XAuthorizationChannel.XAuthorization_WeChat) { platform = 1; } } else { platform = 0; } this._ifly_mgr.OnInitWebViewInfo(platform, XSingleton.singleton.OpenID, XSingleton.singleton.ServerID.ToString(), XSingleton.singleton.Player.PlayerAttributes.RoleID.ToString(), XSingleton.singleton.XPlayerData.Name); } } } } } }