Closed hoomoongoos closed 1 year ago
I don't think OnUserEnableLocalVideo is implemented on WebGL. Try subscribing to OnUserMuteVideo instead.
I've tried it and, to be honest, video-related callbacks are being super inconsistent right now. I've tried using "OnUserEnableLocalVideo", "OnUserMuteVideo" and "OnRemoteVideoStateChanged" to check if a user has enabled their video or not, and there have been times where those callbacks have been fired all the time correctly and other times they've just fired once on startup.
I'm at a point where they just stopped working completely, while I'm absolutely certain that other users local video is being enabled and disabled.
I really don't know what makes it work sometimes but most of the time they won't work at all.
@hoomoongoos our test show the callbacks work properly except it could be too much if all these events are registered. Underneath they corresponds to whether the user's stream is published or not. There isn't a really a one-to-one functional match to muteVideo vs. disableLocalVideo. Please bear in mind that as a wrapper, the WebGL SDK is micmicing the native does but they are not 1-to-1 in parity. I would suggest to use OnUserMuteVideo if you are using the RtcEngine instance or OnRemoteVideoStateChanged if you are using multichannel in your implementation, but not all of them. That said, we will try to implement OnUserEnableLocalVideo as the direct response to this issue.
I agree with @icywind 's previous comment. OnUserEnableLocalVideo hasn't been properly implemented and will need some work before it's functional. But OnUserMuteVideo does seem to work fine with the RtcEngine. I've been testing it myself.
Here's how I'm using the callback:
mRtcEngine.OnUserMuteVideo = userVideoMutedHandler; void userVideoMutedHandler(uint uid, bool muted) { logger.UpdateLog(string.Format("onUserMuteHandler uid: {0}, muted: {1}", uid, muted)); }
I'll be pushing the adjustments I made to the repo. But copy and paste over the following functions in clientManager.js to fix a bug where it's being called too many times:
handleUserPublished():
async handleUserPublished(user, mediaType) { const id = user.uid; if (this.audioSubscribing && mediaType == "audio" && (mediaType == "audio" && this.screenShareClient == null || mediaType == "audio" && this.screenShareClient != null && id != this.screenShareClient.uid)) { await this.subscribe_remoteuser(user, mediaType); } else if(this.videoSubscribing && mediaType == "video" && remoteUsers) { await this.subscribe_remoteuser(user, mediaType); this.getRemoteVideoStats(id); } remoteUsers[id] = user; }
handleUserUnpublished():
handleUserUnpublished(user, mediaType) { const id = user.uid; var strUID = id.toString(); }
this will remove the unnecessary event callback functions for muting when publishing and unpublishing. Let us know how it goes for you and if you're still having trouble with OnUserMuteVideo still.
I've been trying to subscribe a function to the OnUserEnableLocalVideo callback to show or hide each user's canvas when they start or stop streaming their webcam, but the event doesn't seem to be registering properly.
I tried subscribing this next function to the callback event to test if it actually worked, but the console only outputs the Debug.Log message once, as soon as a new user joins the room... Plus, the value of the var "enabled" prints as true, even though I set EnableLocalVideo to false on each user's Awake().
void OnUserEnableLocalVideo(uint uid, bool enabled) { Debug.Log($"{uid} - {enabled}"); }
rtcEngine.OnUserEnableLocalVideo += OnUserEnableLocalVideo;
After the user joins the room, enabling/disabling their local video doesn't trigger the callback function or print anything else on the console anymore.
Full code:
`
`