Exemple #1
0
    static int PlayClipData(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(MicroPhoneInput), typeof(short[])))
            {
                MicroPhoneInput obj  = (MicroPhoneInput)ToLua.ToObject(L, 1);
                short[]         arg0 = ToLua.CheckNumberArray <short>(L, 2);
                obj.PlayClipData(arg0);
                return(0);
            }
            else if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(MicroPhoneInput), typeof(byte[])))
            {
                MicroPhoneInput obj  = (MicroPhoneInput)ToLua.ToObject(L, 1);
                byte[]          arg0 = ToLua.CheckByteBuffer(L, 2);
                obj.PlayClipData(arg0);
                return(0);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: MicroPhoneInput.PlayClipData"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
    void Start()
    {
        try{
            IPAddress[] IPs = Dns.GetHostAddresses(APIS.socketUrl);
            APIS.socketUrl = IPs [0].ToString();

            IPAddress[] IPs2 = Dns.GetHostAddresses(APIS.chatSocketUrl);
            APIS.chatSocketUrl = IPs2 [0].ToString();
        }catch (Exception ex) {
            MyDebug.Log(ex.Message);
        }
        MicroPhoneInput.getInstance();
        GlobalDataScript.getInstance();
        //CustomSocket.getInstance().Connect();
        //ChatSocket.getInstance ();
        TipsManagerScript.getInstance().parent = gameObject.transform;
        SoundCtrl.getInstance();

        //检查更新
        //UpdateScript update = new UpdateScript ();
        //StartCoroutine (update.updateCheck ());

        //ServiceErrorListener seriveError = new ServiceErrorListener();
        Screen.sleepTimeout = SleepTimeout.NeverSleep;
        heartbeatThread();

        StartCoroutine(LoadGD());

        //预加载场景
        StartCoroutine(LoadRes());
    }
Exemple #3
0
    void Awake()
    {
        DontDestroyOnLoad(gameObject);

        _audioSource = transform.GetOrAddComponent <AudioSource>();
        _phoneInput  = MicroPhoneInput.getInstance(gameObject);
    }
    public void OnDownloadChatFinishCallBack(byte[] file)
    {
        //decode byte to audio clip
        AudioClip clip = MicroPhoneInput.ConvertByteToClip(file);

        AddToWaitingForPlayList(clip);

        // TEST CODE
        //AudioPlayer.Instance.PlayAudio(clip, Vector3.zero, false);
    }
 public void EndRecord()
 {
     if (m_CurrentChatStatus == ChatStatus.Record)
     {
         MicroPhoneInput.getInstance().StopRecord();
         ChangeChatStatus(ChatStatus.CD);
         UploadChat();
     }
     // TEST CODE
     //MicroPhoneInput.getInstance().StopRecord();
     //UploadChat();
 }
Exemple #6
0
 public void OnPointerDown()
 {
     if (myScript.avatarList != null && myScript.avatarList.Count > 1)
     {
         btnDown = true;
         InputGameObject.SetActive(true);
         MicroPhoneInput.getInstance().StartRecord(getUserList());
     }
     else
     {
         TipsManagerScript.getInstance().setTips("房间里只有你一个人,不能发送语音");
     }
 }
Exemple #7
0
 static int GetVoiceData(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 0);
         LuaInterface.LuaByteBuffer o = MicroPhoneInput.GetVoiceData();
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemple #8
0
 static int getInstance(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 0);
         MicroPhoneInput o = MicroPhoneInput.getInstance();
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemple #9
0
    public float SetText(string text)
    {
        if (_microPhoneInput == null)
        {
            _microPhoneInput = NGUITools.FindInParents <MicroPhoneInput>(gameObject);
            emojiContainer   = transform.Find("emojis");
            faceTemplate     = transform.Find("Sprite").gameObject;
            faceTemplate.SetActive(false);
            _lblChatInfo = transform.GetComponent <UILabelCustom>();
            if (!isColorSet)
            {
                curColor   = _lblChatInfo.color;
                isColorSet = true;
            }
            if (_lblChatInfo.gameObject.GetComponent <BoxCollider>() == null)
            {
                _lblChatInfo.gameObject.AddComponent <BoxCollider>();
            }
        }

        emojiContainer.DestroyChildren();

        _lblChatInfo.color = Color.white;
        text = NGUIText.EncodeColor(text, curColor);
        _lblChatInfo.ProcessText();
        _lblChatInfo.UpdateNGUIText();
        cellLength = _lblChatInfo.fontSize + _lblChatInfo.floatSpacingY;

        _lblChatInfo.text = SetEmoji(text, (faceName) => {
            AnimationVO aniConfig;
            aniConfig = GameConst.GetAnimationConfigByIndex(faceName);
            //根据文本算出表情的初步坐标(如果后面添加了更高的表情需要重新调整位置)
            GameObject sprite = ReplaceEmojiWithPicture(faceName);
            Vector3 temPos;
            sprites.Add(sprite);

            //对齐同一行的表情
            float vetY = sprite.transform.localPosition.y - cellLength * (aniConfig.rowNum - 1);
            for (int i = 0; i < sprites.Count; i++)
            {
                aniConfig = GameConst.GetAnimationConfigByIndex(sprites[i].name);
                temPos    = sprites[i].transform.localPosition;
                temPos.y  = vetY + (aniConfig.rowNum - 1) * cellLength;
                sprites[i].transform.localPosition = temPos;
            }
        });
        _lblChatInfo.ResizeCollider();
        isUseUrl = _isUseUrl;
        return(rowDict[rowList[0]] * cellLength);
    }
 static int StopRecord(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         MicroPhoneInput obj = (MicroPhoneInput)ToLua.CheckObject <MicroPhoneInput>(L, 1);
         obj.StopRecord();
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemple #11
0
 void Start()
 {
     btnStartRecord.onClick.AddListener(() => {
         MicroPhoneInput.getInstance().StartRecord();
     });
     btnStopRecord.onClick.AddListener(() => {
         MicroPhoneInput.getInstance().StopRecord();
     });
     btnPlayRecord.onClick.AddListener(() => {
         MicroPhoneInput.getInstance().PlayRecord();
     });
     btnPlayStream.onClick.AddListener(() => {
         MicroPhoneInput.getInstance().PlayClipData(MicroPhoneInput.getInstance().GetClipDataInFloat());
     });
 }
Exemple #12
0
 static int GetClipData(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         MicroPhoneInput            obj = (MicroPhoneInput)ToLua.CheckObject(L, 1, typeof(MicroPhoneInput));
         LuaInterface.LuaByteBuffer o   = obj.GetClipData();
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemple #13
0
 static int IsRecording(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         MicroPhoneInput obj = (MicroPhoneInput)ToLua.CheckObject(L, 1, typeof(MicroPhoneInput));
         bool            o   = obj.IsRecording();
         LuaDLL.lua_pushboolean(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int PlayClipData(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         MicroPhoneInput obj  = (MicroPhoneInput)ToLua.CheckObject <MicroPhoneInput>(L, 1);
         short[]         arg0 = ToLua.CheckNumberArray <short>(L, 2);
         obj.PlayClipData(arg0);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int GetClipData(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         MicroPhoneInput obj = (MicroPhoneInput)ToLua.CheckObject <MicroPhoneInput>(L, 1);
         byte[]          o   = obj.GetClipData();
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int CompressBytes(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         byte[] arg0 = ToLua.CheckByteBuffer(L, 1);
         byte[] o    = MicroPhoneInput.CompressBytes(arg0);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int GetAveragedVolume(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         MicroPhoneInput obj = (MicroPhoneInput)ToLua.CheckObject <MicroPhoneInput>(L, 1);
         float           o   = obj.GetAveragedVolume();
         LuaDLL.lua_pushnumber(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemple #18
0
 static int DeCompress(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         MicroPhoneInput obj  = (MicroPhoneInput)ToLua.CheckObject(L, 1, typeof(MicroPhoneInput));
         byte[]          arg0 = ToLua.CheckByteBuffer(L, 2);
         byte[]          o    = obj.DeCompress(arg0);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
 static int ByteToInt(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         MicroPhoneInput obj  = (MicroPhoneInput)ToLua.CheckObject <MicroPhoneInput>(L, 1);
         byte[]          arg0 = ToLua.CheckByteBuffer(L, 2);
         short[]         o    = obj.ByteToInt(arg0);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemple #20
0
    void Update()
    {
        string[] d = MicroPhoneInput.getInstance().GetDeviceList();
        for (int i = 0; i < d.Length; i++)
        {
            txtDEV.text = d [i];
        }

        float volume = MicroPhoneInput.getInstance().GetAveragedVolume();

        if (volume > 0f)
        {
            txtVOC.text = volume.ToString();
            mCube.AddForce(Vector3.up * volume * 300f);
        }
    }
Exemple #21
0
    void Start()
    {
        MicroPhoneInput.getInstance();
        GlobalDataScript.getInstance();
        TipsManagerScript.getInstance().parent = gameObject.transform;
        SoundCtrl.getInstance();

        //UpdateScript update = new UpdateScript ();
        //StartCoroutine (update.updateCheck ());
        ServiceErrorListener seriveError = new ServiceErrorListener();

        Screen.sleepTimeout = SleepTimeout.NeverSleep;
        //heartBeatThread();
        heartBeatTimer();

        amap.StartLocation();
    }
    static int set_Device(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            MicroPhoneInput obj  = (MicroPhoneInput)o;
            string          arg0 = ToLua.CheckString(L, 2);
            obj.Device = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index Device on a nil value"));
        }
    }
    static int set_loudness(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            MicroPhoneInput obj  = (MicroPhoneInput)o;
            float           arg0 = (float)LuaDLL.luaL_checknumber(L, 2);
            obj.loudness = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index loudness on a nil value"));
        }
    }
    static int set_m_instance(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            MicroPhoneInput obj  = (MicroPhoneInput)o;
            MicroPhoneInput arg0 = (MicroPhoneInput)ToLua.CheckObject <MicroPhoneInput>(L, 2);
            obj.m_instance = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index m_instance on a nil value"));
        }
    }
    static int get_Device(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            MicroPhoneInput obj = (MicroPhoneInput)o;
            string          ret = obj.Device;
            LuaDLL.lua_pushstring(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index Device on a nil value"));
        }
    }
    static int get_loudness(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            MicroPhoneInput obj = (MicroPhoneInput)o;
            float           ret = obj.loudness;
            LuaDLL.lua_pushnumber(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index loudness on a nil value"));
        }
    }
    static int get_audio(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            MicroPhoneInput         obj = (MicroPhoneInput)o;
            UnityEngine.AudioSource ret = obj.audio;
            ToLua.PushSealed(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index audio on a nil value"));
        }
    }
    static int get_m_instance(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            MicroPhoneInput obj = (MicroPhoneInput)o;
            MicroPhoneInput ret = obj.m_instance;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index m_instance on a nil value"));
        }
    }
Exemple #29
0
	public float SetText(string text) {
		if (_microPhoneInput == null) {
			_microPhoneInput = NGUITools.FindInParents<MicroPhoneInput>(gameObject);
			emojiContainer = transform.Find("emojis");
			faceTemplate = transform.Find("Sprite").gameObject;
			faceTemplate.SetActive(false);
			_lblChatInfo = transform.GetComponent<UILabelCustom>();
			if (!isColorSet) {
				curColor = _lblChatInfo.color;
				isColorSet = true;
			}
			if (_lblChatInfo.gameObject.GetComponent<BoxCollider>() == null) {
				_lblChatInfo.gameObject.AddComponent<BoxCollider>();
			}
			
		}

		emojiContainer.DestroyChildren();

		_lblChatInfo.color = Color.white;
		text = NGUIText.EncodeColor(text, curColor);
		_lblChatInfo.ProcessText();
		_lblChatInfo.UpdateNGUIText();
		cellLength = _lblChatInfo.fontSize + _lblChatInfo.floatSpacingY;

		_lblChatInfo.text = SetEmoji(text, (faceName) => {
			AnimationVO aniConfig;
			aniConfig = GameConst.GetAnimationConfigByIndex(faceName);
			//根据文本算出表情的初步坐标(如果后面添加了更高的表情需要重新调整位置)
			GameObject sprite = ReplaceEmojiWithPicture(faceName);
			Vector3 temPos;
			sprites.Add(sprite);

			//对齐同一行的表情
			float vetY = sprite.transform.localPosition.y - cellLength * (aniConfig.rowNum - 1);
			for (int i = 0; i < sprites.Count; i++) {
				aniConfig = GameConst.GetAnimationConfigByIndex(sprites[i].name);
				temPos = sprites[i].transform.localPosition;
				temPos.y = vetY + (aniConfig.rowNum - 1) * cellLength;
				sprites[i].transform.localPosition = temPos;
			}
		});
		_lblChatInfo.ResizeCollider();
		isUseUrl = _isUseUrl;
		return rowDict[rowList[0]] * cellLength;
	}
    static int set_audio(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            MicroPhoneInput         obj  = (MicroPhoneInput)o;
            UnityEngine.AudioSource arg0 = (UnityEngine.AudioSource)ToLua.CheckObject(L, 2, typeof(UnityEngine.AudioSource));
            obj.audio = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index audio on a nil value"));
        }
    }
Exemple #31
0
 public void OnPointerUp()
 {
     if (btnDown)
     {
         btnDown = false;
         InputGameObject.SetActive(false);
         WholeTime = 10;
         if (myScript.avatarList != null && myScript.avatarList.Count > 1)
         {
             MicroPhoneInput.getInstance().StopRecord();
             myScript.myselfSoundActionPlay();
         }
         else
         {
         }
     }
 }
Exemple #32
0
	public override void OnLoadedUI(bool close3dTouch, object args) {
		base.OnLoadedUI(close3dTouch, args);

		_chatPanel = transform.Find("all_bf").gameObject;
		_chatWidget = transform.Find("all_bf/xinxikuang/Container").GetComponent<UIWidget>();
		_btnTextInput = transform.Find("all_bf/text_button").gameObject;
		_btnVoiceInput = transform.Find("all_bf/voice_button ").gameObject;
		_chatScrollPanel = transform.Find("all_bf/xinxikuang/Container/Scroll View").GetComponent<UIPanel>();
		_chatScrollView = transform.Find("all_bf/xinxikuang/Container/Scroll View").GetComponent<UIScrollView>();
		_tableChatPanel = transform.Find("all_bf/xinxikuang/Container/Scroll View/Table").GetComponent<UITable>();
		_lockMessage = transform.Find("all_bf/xinxikuang/Container/Panel/Message").gameObject;
		_labelLock = transform.Find("all_bf/xinxikuang/Container/Panel/Message/Label").GetComponent<UILabel>();

		_textTemplate = transform.Find("all_bf/xinxikuang/Container/Scroll View/text_template").gameObject;
		_microPhoneInput = _chatPanel.GetComponent<MicroPhoneInput>();
		_voiceOn = transform.Find("all_bf/voice_button /buttom_on").gameObject;
		_textTemplate.SetActive(false);

		_chatInfoItems = new TableItemList<ChatInfoItem>(null, this);

		_playName = "王五";

		_tablePosition = _tableChatPanel.transform.localPosition;
		_scrollPosition = _chatScrollView.transform.localPosition;
		_panelOffset = _chatScrollPanel.clipOffset;
		_chatDataList = ChatDataManager.GetInstance().chatDataList;

		HideLockMessage();
		_chatScrollView.onMomentumMove = () => {
			if (CheckChatPanelBottom() && _lockMessgeNum > 0) {
				RefreshChatPanel();
				HideLockMessage();
			}
		};

		#region 注册点击函数
		RegistOnPress(_btnVoiceInput, VoiceInputPress);
		RegistUIButton(_lockMessage, LockClick);
		RegistUIButton(_btnTextInput, (go) => {
			GetParentUI<ChatView>().chatDetailView.RefreshOpen();
		});
		#endregion
	}
 public static MicroPhoneInput getInstance()
 {
     if (m_instance == null)
     {
         micArray = Microphone.devices;
         if (micArray.Length == 0)
         {
             Debug.LogError("Microphone.devices is null");
         }
         foreach (string deviceStr in Microphone.devices)
         {
             Debug.Log("device name = " + deviceStr);
         }
         if (micArray.Length == 0)
         {
             Debug.LogError("no mic device");
         }
         m_instance = new MicroPhoneInput();
     }
     return m_instance;
 }