| | |
| | | using System;
|
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using System.Collections;
|
| | | using System.Collections.Generic;
|
| | | using System.Text;
|
| | | using UnityEngine; |
| | | |
| | | using UnityEngine;
|
| | |
|
| | | [XLua.LuaCallCSharp]
|
| | | public class VoiceHttpRequest : SingletonMonobehaviour<VoiceHttpRequest>
|
| | | |
| | | { |
| | |
|
| | | {
|
| | | const string uploadUrl = "http://{0}.voice.2460web.com:53001/voice/upload";
|
| | | const string downloadUrl = "http://{0}.voice.2460web.com:53001/voice/download"; |
| | | |
| | | |
| | | public Queue<VoiceHttp> speechs = new Queue<VoiceHttp>(); |
| | | public Queue<VoiceDecodec> decodecSamples = new Queue<VoiceDecodec>(); |
| | | |
| | | public event Action<VoiceDecodec> samplesDecodecComplete; |
| | | |
| | | private bool onceSuccessRemind = false; |
| | | |
| | | const string downloadUrl = "http://{0}.voice.2460web.com:53001/voice/download";
|
| | |
|
| | |
|
| | | public Queue<VoiceHttp> speechs = new Queue<VoiceHttp>();
|
| | | public Queue<VoiceDecodec> decodecSamples = new Queue<VoiceDecodec>();
|
| | |
|
| | | public event Action<VoiceDecodec> samplesDecodecComplete;
|
| | |
|
| | | private bool onceSuccessRemind = false;
|
| | |
|
| | | private void Awake()
|
| | | {
|
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += OnBeforePlayerDataInitialize;
|
| | | StageManager.Instance.onStageLoadFinish += OnStageLoadFinish;
|
| | | StageLoad.Instance.onStageLoadFinish += OnStageLoadFinish;
|
| | | }
|
| | |
|
| | | private void OnStageLoadFinish()
|
| | | {
|
| | | if (StageManager.Instance.CurrentStage is LoginStage)
|
| | | if (StageLoad.Instance.currentStage is LoginStage)
|
| | | {
|
| | | speechs.Clear();
|
| | | }
|
| | |
| | | playerId = _playerId
|
| | | });
|
| | | onceSuccessRemind = false;
|
| | | } |
| | | |
| | | }
|
| | |
|
| | | private void LateUpdate()
|
| | | {
|
| | | if (speechs.Count > 0)
|
| | |
| | | {
|
| | | samplesDecodecComplete(decodecSamples.Dequeue());
|
| | | }
|
| | | } |
| | | |
| | | }
|
| | |
|
| | | public void Enqueue(float[] _samples, long _tick, int _playerId)
|
| | | {
|
| | | decodecSamples.Enqueue(new VoiceDecodec()
|
| | |
| | | samples = _samples,
|
| | | playerId = _playerId,
|
| | | });
|
| | | } |
| | | |
| | | }
|
| | |
|
| | | public struct VoiceHttp
|
| | | {
|
| | | public byte[] encode;
|
| | | public long tick;
|
| | | public int playerId;
|
| | | } |
| | | |
| | | }
|
| | |
|
| | | public struct VoiceDecodec
|
| | | {
|
| | | public long tick;
|
| | | public int playerId;
|
| | | public float[] samples;
|
| | | } |
| | | } |
| | | }
|
| | | }
|