Speaker stops working if its GameObject is deactivated
Options
spag007
✭
in Photon Voice
I've been struggling with this issue for a while:
When creating a room with players using PUN 2, voice transmission works fine, everyone is able to hear everyone else.
However, if I deactivate a certain player's GameObject (that contains a PhotonView, PhotonVoiceView and a Speaker), when enabling it again its Speaker simply stops working. So long as other player's GameObjects don't get deactivated and then reactivated, their Speakers seem to work fine. I get the following related errors in the console:
- [PhotonVoiceConnection.PhotonVoiceNetwork] 2021-05-06T19:04:17:Speaker is null. Remote voice 2/2 not linked.
- Coroutine couldn't be started because the the game object '[player's gameobject name]' is inactive!
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
Photon.Voice.Unity.Speaker:StartPlaying() (at Assets/Photon/PhotonVoice/Code/Speaker.cs:376)
- NullReferenceException: routine is null
UnityEngine.MonoBehaviour.StopCoroutine (UnityEngine.Coroutine routine) (at <29ad182faa3f478c9310d6a2e7143c15>:0)
Photon.Voice.Unity.Speaker.StopPlaying () (at Assets/Photon/PhotonVoice/Code/Speaker.cs:426)
Photon.Voice.Unity.Speaker.OnRemoteVoiceRemove () (at Assets/Photon/PhotonVoice/Code/Speaker.cs:300)
- [PhotonVoiceConnection.PhotonVoiceNetwork] 2021-05-06T19:40:47:UserData (null) does not contain PhotonViewId. Remote voice 2/1 not linked. Do you have a Recorder not used with a PhotonVoiceView? is this expected?
UnityEngine.Debug:LogWarningFormat(Object, String, Object[])
Photon.Voice.Unity.VoiceLogger:LogWarning(String, Object[]) (at Assets/Photon/PhotonVoice/Code/VoiceLogger.cs:81)
I've tried using Speaker.RestartPlayback() in the PhotonUser's OnEnable() method, I've tried adding the Speaker component by script in OnEnable() and destroying it in OnDisable(), I've tried enabling the Speaker's PlaybackOnlyWhenEnabled, I've tried deactivating the MRTK's spatializer, none of which seem to work as of yet. I've made sure that the issue is not with the Recorder, everything seems to work fine on that side.
For some reason, if I repeatedly activate and deactivate the player's Speaker's PlaybackOnlyWhenEnabled in the editor in play mode, it sometimes makes it work, until the GameObject is deactivated again.
Everything works on PUN's side, the problem seems to be only with PUN Voice. I've searched the web and forums extensively but I have yet to find a solution.
Here are my specs:
Pun 2 - FREE 2.30.0 (will upgrade to Pro close to launch if app is successful)
Photon Voice 2 2.24.1
Unity 2019.4.16f1
MRTK 2.5.3
Azure Spatial Anchors 2.7.0
Deploying to Hololens 2 - UWP ARM Architecture
Any idea as to what the issue may be ?
When creating a room with players using PUN 2, voice transmission works fine, everyone is able to hear everyone else.
However, if I deactivate a certain player's GameObject (that contains a PhotonView, PhotonVoiceView and a Speaker), when enabling it again its Speaker simply stops working. So long as other player's GameObjects don't get deactivated and then reactivated, their Speakers seem to work fine. I get the following related errors in the console:
- [PhotonVoiceConnection.PhotonVoiceNetwork] 2021-05-06T19:04:17:Speaker is null. Remote voice 2/2 not linked.
- Coroutine couldn't be started because the the game object '[player's gameobject name]' is inactive!
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
Photon.Voice.Unity.Speaker:StartPlaying() (at Assets/Photon/PhotonVoice/Code/Speaker.cs:376)
- NullReferenceException: routine is null
UnityEngine.MonoBehaviour.StopCoroutine (UnityEngine.Coroutine routine) (at <29ad182faa3f478c9310d6a2e7143c15>:0)
Photon.Voice.Unity.Speaker.StopPlaying () (at Assets/Photon/PhotonVoice/Code/Speaker.cs:426)
Photon.Voice.Unity.Speaker.OnRemoteVoiceRemove () (at Assets/Photon/PhotonVoice/Code/Speaker.cs:300)
- [PhotonVoiceConnection.PhotonVoiceNetwork] 2021-05-06T19:40:47:UserData (null) does not contain PhotonViewId. Remote voice 2/1 not linked. Do you have a Recorder not used with a PhotonVoiceView? is this expected?
UnityEngine.Debug:LogWarningFormat(Object, String, Object[])
Photon.Voice.Unity.VoiceLogger:LogWarning(String, Object[]) (at Assets/Photon/PhotonVoice/Code/VoiceLogger.cs:81)
I've tried using Speaker.RestartPlayback() in the PhotonUser's OnEnable() method, I've tried adding the Speaker component by script in OnEnable() and destroying it in OnDisable(), I've tried enabling the Speaker's PlaybackOnlyWhenEnabled, I've tried deactivating the MRTK's spatializer, none of which seem to work as of yet. I've made sure that the issue is not with the Recorder, everything seems to work fine on that side.
For some reason, if I repeatedly activate and deactivate the player's Speaker's PlaybackOnlyWhenEnabled in the editor in play mode, it sometimes makes it work, until the GameObject is deactivated again.
Everything works on PUN's side, the problem seems to be only with PUN Voice. I've searched the web and forums extensively but I have yet to find a solution.
Here are my specs:
Pun 2 - FREE 2.30.0 (will upgrade to Pro close to launch if app is successful)
Photon Voice 2 2.24.1
Unity 2019.4.16f1
MRTK 2.5.3
Azure Spatial Anchors 2.7.0
Deploying to Hololens 2 - UWP ARM Architecture
Any idea as to what the issue may be ?
0