Пример #1
0
 public void StopRecording()
 {
     if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.OSXEditor)
     {
         return;
     }
     if (m_voiceengine != null)
     {
         GCloudVoiceErr err = (GCloudVoiceErr)m_voiceengine.StopRecording();
         if (err != GCloudVoiceErr.GCLOUD_VOICE_SUCC)
         {
             Debug.LogError("[GVoiceMng.StopRecording]StopRecording:" + err);
         }
         else
         {
             if (!IsCancelRecording)
             {
                 GCloudVoiceErr uperr = (GCloudVoiceErr)m_voiceengine.UploadRecordedFile(uploadPath, 60000);
                 if (uperr != GCloudVoiceErr.GCLOUD_VOICE_SUCC)
                 {
                     Debug.LogError("[GVoiceMng.StopRecording]UploadRecordedFile:" + uperr);
                 }
             }
             else
             {
                 Debug.Log("取消上传录音");
             }
         }
     }
     IsCancelRecording = false;
 }
Пример #2
0
 public void DownloadRecordedFile(string strShareFileID, string strFileName)
 {
     if (!string.IsNullOrEmpty(strShareFileID))
     {
         if (m_voiceengine != null)
         {
             if (m_strDownLoadingFileid.Equals(strShareFileID))
             {
                 return;
             }
             m_strDownLoadingFileid = strShareFileID;
             string filePath = string.Format("{0}/{1}.amr", VoiceDataPath, strFileName);
             if (m_GCloudVoiceMode == GCloudVoiceMode.RealTime)
             {
                 CloseMic();
                 CloseSpeaker();
                 SetModel(GCloudVoiceMode.Translation);
             }
             GCloudVoiceErr error = (GCloudVoiceErr)m_voiceengine.DownloadRecordedFile(strShareFileID, filePath, 6000);
             if (error != 0)
             {
                 SetRealTimeModel();
             }
             Debug.Log("DownloadRecordedFile error:" + error);
         }
     }
 }
Пример #3
0
    /// <summary>
    /// 取消录制
    /// </summary>
    public void StopRecording()
    {
        if (m_voiceengine == null)
        {
            return;
        }
        GCloudVoiceErr error = (GCloudVoiceErr)m_voiceengine.StopRecording();

        Debug.Log("GVoiceManger StopRecording error:" + error);
        if (error != GCloudVoiceErr.GCLOUD_VOICE_SUCC)
        {
            m_filePath = "";
            SetRealTimeModel();
        }
    }
Пример #4
0
 public void StartRecording()
 {
     if (Application.platform == RuntimePlatform.WindowsEditor || Application.platform == RuntimePlatform.OSXEditor)
     {
         return;
     }
     if (m_voiceengine != null)
     {
         GCloudVoiceErr err = (GCloudVoiceErr)m_voiceengine.StartRecording(uploadPath);
         if (err != GCloudVoiceErr.GCLOUD_VOICE_SUCC)
         {
             Debug.LogError("[GVoiceMng.StartRecording]:" + err);
         }
     }
 }
Пример #5
0
 void downloadRecord()
 {
     if (isPlaySucc && records.Count > 0)
     {
         isPlaySucc = false;
         string         recordID = records.Dequeue();
         GCloudVoiceErr err      = (GCloudVoiceErr)m_voiceengine.DownloadRecordedFile(recordID, downloadPath, 60000);
         if (err != GCloudVoiceErr.GCLOUD_VOICE_SUCC)
         {
             Debug.LogError("[GVoiceMng.StopRecording]UploadRecordedFile:" + err);
             isPlaySucc = true;
             downloadRecord();
         }
     }
 }
Пример #6
0
 void onDownloadReccordFileComplete(IGCloudVoice.GCloudVoiceCompleteCode code, string filepath, string fileid)
 {
     if (code == IGCloudVoice.GCloudVoiceCompleteCode.GV_ON_DOWNLOAD_RECORD_DONE)
     {
         Debug.Log("OnDownloadRecordFileComplete succ, filepath:" + filepath + " fileid:" + fileid);
         GCloudVoiceErr err = (GCloudVoiceErr)m_voiceengine.PlayRecordedFile(filepath);
         if (err != GCloudVoiceErr.GCLOUD_VOICE_SUCC)
         {
             Debug.LogError("[GVoiceMng.onDownloadReccordFileComplete]PlayRecordedFile:" + err);
             isPlaySucc = true;
             downloadRecord();
         }
     }
     else
     {
         Debug.Log("OnDownloadRecordFileComplete error");
     }
 }
Пример #7
0
    /// <summary>
    /// 当录制完成后,调用UploadRecordedFile将文件上传到GcloudVoice的服务器上,
    /// 该过程会通过OnUploadReccordFileComplete回调在上传成功的时候返还一个ShareFileID.该ID是这个文件的唯一标识符,
    /// 用于其他用户收听时候的下载。服务器需要对其进行管理和转发
    /// </summary>
    public void UploadRecordedFile()
    {
        if (!string.IsNullOrEmpty(m_filePath))
        {
            int[] bytes = new int[1];
            bytes[0] = 0;
            float[] seconds = new float[1];
            seconds[0] = 0;

            if (m_GCloudVoiceMode != GCloudVoiceMode.Translation)
            {
                SetModel(GCloudVoiceMode.Translation);
            }

            m_voiceengine.GetFileParam(m_filePath, bytes, seconds);
            Debug.Log("GVoiceManger UploadRecordedFile m_filePath:" + m_filePath + " seconds :" + seconds[0]);
            if (seconds[0] <= 0)
            {
                TipsManager.Instance.ShowTips("输入语音过短");
                SetRealTimeModel();
                return;
            }

            GCloudVoiceErr error = (GCloudVoiceErr)m_voiceengine.UploadRecordedFile(m_filePath, 6000);
            if (error != GCloudVoiceErr.GCLOUD_VOICE_SUCC)
            {
                TipsManager.Instance.ShowTips("语音发送成功");
                SetRealTimeModel();
            }
            Debug.Log("GVoiceManger UploadRecordedFile error:" + error);
        }
        else
        {
            SetRealTimeModel();
        }
    }