The problem with voice chat.

Alex333
Alex333
edited August 2019 in Photon Voice
after connecting 2 players disconnect occurs.
https://drive.google.com/open?id=1VlHtsTBcf761c4Wkx1T9S3JLKN73Gxp0
https://drive.google.com/open?id=1v6IG107VjxN9NojY3lnuW5gRMzY5lRWi

Sequencing:
Connect to PhotonNetwork Room
Loading the level at which there is an object with the PhotonVoiceNetwork component (screenshot)
https://drive.google.com/open?id=1VlHtsTBcf761c4Wkx1T9S3JLKN73Gxp0

Installing a player with VoiceView and Recorder components
https://drive.google.com/open?id=1CGv7gCMAQkEYgq_4q67Q-PZzWs3_T6YR
https://drive.google.com/open?id=101eGKbESz87rxOHS6viguqaDd5W78AMF
Next, control passes to the script:
public class VoiceController : MonoBehaviour
{
    public PhotonVoiceView punVoice;
    public static VoiceController instance;

    void Awake()
    {
        AsyncEvents.fullSceneLoaded += Init;
        punVoice = gameObject.GetComponent<PhotonVoiceView>();
        punVoice.enabled = false;
    }

    private void Init()
    {
        AsyncEvents.fullSceneLoaded -= Init;
        PhotonVoiceNetwork.Instance.Client.StateChanged += CheckInitState;
        PhotonVoiceNetwork.Instance.ConnectAndJoinRoom();
    }

    private void OnDestroy()
    {
        AsyncEvents.fullSceneLoaded -= Init;
        if (PhotonVoiceNetwork.Instance == null) return;
        PhotonVoiceNetwork.Instance.Client.StateChanged -= CheckInitState;
    }

    private void CheckInitState(ClientState fromState, ClientState toState)
    {
        if (toState == ClientState.Joined)
        {
            punVoice.enabled = true;
        }
    }

    void OnEnable()
    {
        instance = this;
    }

    void OnDisable()
    {
        instance = null;
    }

    public void SetType(bool b)
    {
        if(punVoice == null) return;
        punVoice.RecorderInUse.TransmitEnabled = b;
    }

    void Update()
    {
        if (!punVoice.enabled) return;
        if(!ExtraConfig.voiceType)
        {
            punVoice.RecorderInUse.TransmitEnabled = Input.GetKey(InputConfig.voice);
        }
    }
}

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Hi @Alex333,

    What Photon Voice version is this?
    Can you reproduce using a demo scene from the Photon Voice package?

    From the screenshot, what I can see is that you have PhotonVoiceNetwork.AutoConnectAndJoin set to false but the PhotonVoiceNetwork is still trying to connect and join a room. This means that you are manually connecting PhotonVoiceNetwork. May I know why? I think you should set PhotonVoiceNetwork.AutoConnectAndJoin to true and do not interfere with the PhotonVoiceNetwork flow.

    While I did not get why you need the custom script to enable PhotonVoiceView when the Voice client is joined to a room, it's still not related to the disconnection issue. As the disconnection happen before.
  • Alex333
    Alex333
    edited August 2019
    JohnTube said:

    Hi @Alex333,

    What Photon Voice version is this?
    Can you reproduce using a demo scene from the Photon Voice package?

    From the screenshot, what I can see is that you have PhotonVoiceNetwork.AutoConnectAndJoin set to false but the PhotonVoiceNetwork is still trying to connect and join a room. This means that you are manually connecting PhotonVoiceNetwork. May I know why? I think you should set PhotonVoiceNetwork.AutoConnectAndJoin to true and do not interfere with the PhotonVoiceNetwork flow.

    While I did not get why you need the custom script to enable PhotonVoiceView when the Voice client is joined to a room, it's still not related to the disconnection issue. As the disconnection happen before.

    Good day. we did as you wrote. The first player comes in. Now the Recorder script writes a warning (screenshot) Voice chat still does not work. what do we need to do?
    https://drive.google.com/open?id=1Fk3ZZb_XdRmP3UXtvKXsJ7zb8d-lIfGH

    script
    public class VoiceController : MonoBehaviour
    {
        public PhotonVoiceView punVoice;
        public static VoiceController instance;
    
        void Awake()
        {
            punVoice = gameObject.GetComponent<PhotonVoiceView>();
        }
    
        void OnEnable()
        {
            instance = this;
        }
    
        void OnDisable()
        {
            instance = null;
        }
    
        public void SetType(bool b)
        {
            if(punVoice == null) return;
            punVoice.RecorderInUse.TransmitEnabled = b;
        }
    
        void Update()
        {
            if (!punVoice.enabled) return;
            if(!ExtraConfig.voiceType)
            {
                punVoice.RecorderInUse.TransmitEnabled = Input.GetKey(InputConfig.voice);
            }
        }
    }

  • JohnTube
    JohnTube ✭✭✭✭✭
    edited August 2019
    Hi @Alex333,

    That warning will go away on itself when the recorder is automatically initialized which is the case for the PUN integration.
    Take a look and try the DemoVoicePun scene for yourself.

    Make sure Recorder.TransmitEnabled is enabled (ticked/checked, set to true).

    I'm still convinced you do not need the VoiceController.

    I also tried your setup: Recorder component in the prefab and set in PhotonVoiceView.RecorderInUse and UsePrimaryRecorder disabled. It works for me.

    Can you reproduce this issue with the DemoVoicePun scene?
    What are the minimal repro steps?