示例#1
0
    void Start()
    {
        if (!photonView.IsMine)
        {
            return;
        }

        audioListener.enabled = true;

        if (!CustomMicrophone.HasConnectedMicrophoneDevices())
        {
            CustomMicrophone.RefreshMicrophoneDevices();
        }
        Debug.Log(CustomMicrophone.devices.Length + " microphone devices found");

        if (!CustomMicrophone.HasConnectedMicrophoneDevices())
        {
            Debug.Log("no microphone device connected");
        }

        _microphoneDevice = CustomMicrophone.devices[0];
        audioClip         = CustomMicrophone.Start(_microphoneDevice, true, lengthSec, frequency);

        //subscribe to events
        VoiceChat.Instance.OnStatusUpdate += OnStatusupdate;
        VoiceChat.Instance.OnIDUpdate     += OnIDUpdate;

        //initialize peer object for this client
        VoiceChat.Instance.InitializePeer();
    }
示例#2
0
        private void RefreshMicrophoneDevicesButtonOnclickHandler()
        {
            RequestPermission();
            CustomMicrophone.RefreshMicrophoneDevices();

            if (!CustomMicrophone.HasConnectedMicrophoneDevices())
            {
                return;
            }

            devicesDropdown.ClearOptions();
            devicesDropdown.AddOptions(CustomMicrophone.devices.ToList());
            DevicesDropdownValueChangedHandler(0);
        }
    // Start is called before the first frame update
    void Start()
    {
        var voice = GameObject.Find("[PeerJS]VoiceChat");

        if (voice != null)
        {
            Destroy(voice);
        }

        var microphone = GameObject.Find("[FG]Microphone");

        if (microphone != null)
        {
            if (CustomMicrophone.IsRecording(CustomMicrophone.devices[0]))
            {
                CustomMicrophone.End(CustomMicrophone.devices[0]);
            }
            Destroy(microphone);
        }



        // request microphone permissions at the start of the menu
        if (!CustomMicrophone.HasMicrophonePermission())
        {
            CustomMicrophone.RequestMicrophonePermission();
        }
        if (!CustomMicrophone.HasConnectedMicrophoneDevices())
        {
            CustomMicrophone.RefreshMicrophoneDevices();
        }
        //Debug.Log(CustomMicrophone.devices.Length + " microphone devices found");

        // destroys game tracker from previous game
        if (GameObject.FindGameObjectWithTag("GameTracker") != null)
        {
            Destroy(GameObject.FindGameObjectWithTag("GameTracker"));
        }

        // disconnects the player if they were already connected
        if (PhotonNetwork.IsConnected)
        {
            PhotonNetwork.Disconnect();
            Cursor.lockState = CursorLockMode.None;
            Cursor.visible   = true;
        }
        PhotonNetwork.ConnectUsingSettings();
        //Debug.Log(PhotonNetwork.PhotonServerSettings);
    }
示例#4
0
 /// <summary>
 /// Requests microphone perission and refreshes list of microphones if WebGL platform
 /// </summary>
 public void RefreshMicrophones()
 {
     CustomMicrophone.RequestMicrophonePermission();
     CustomMicrophone.RefreshMicrophoneDevices();
 }