Skip to content
This repository has been archived by the owner on Oct 14, 2022. It is now read-only.

Not getting "user-unpublished" event when unpublishing a local video track #8

Closed
aravindm opened this issue Apr 19, 2020 · 4 comments
Closed
Labels
bug Something isn't working

Comments

@aravindm
Copy link

Hello there,

I am trying to unpublish the local video track with the below code to mute the video and switch off the camera indicator:

client.unpublish([localVideoTrack])
localVideoTrack.close()
localVideoTrack = null

When I execute the above code, the video stops for the local user as expected but on the remote users end, the video freezes and I am not getting a "user-unpublished" event callback. I've registered for the event on the remote users end with the following code:

client.on('user-unpublished', (user, mediaType) => {
console.log('unpublished', user, mediaType)
})

When I refresh the page on the remote users end, I can see the above console log statement though.
Could you please let me know if I have to do something else to get the callbacks working?

Thanks!

@disoul disoul added the bug Something isn't working label Apr 19, 2020
@disoul
Copy link
Collaborator

disoul commented Apr 19, 2020

Thanks for your feedback.

This bug is caused by Agora’s WebRTC gateway, so I cannot fix it by releasing a new SDK version.

But here is a workaround to fix this. Just call localVideoTrack.setMute(true) before client.unpublish. In this case, the remote video will be black and remote end can receive a user-unpublished event.

I created a codepen to show you how to work around it, check out this

Agora's WebRTC gateway will fix this bug in the future. I will notify in this issue when the gateway is ready

@aravindm
Copy link
Author

Thank you for your response @disoul . The codepen shared by you works, although I found out that it doesn't send the unpublished event in one specific scenario, if the audiotrack is muted before it is published and then you mute & unpublish the video track.

You can add the below line at line 34 in your code pen to reproduce the same:
localAudio.setMute(true)

Please do let me know if there is a way I can get the "user-unpublished" event consistently or if I should use the mute event instead.

@disoul
Copy link
Collaborator

disoul commented Apr 20, 2020

In fact, we are considering to delete the setMute API and user-mute-updated event. Many developers are confused about this API, and this API has caused many problems. If you want to mute a LocalTrack, you can also call LocalTrack.stop() and client.unpublish.(maybe we will provide a new API to help you to do this in the future version)

So I don't recommend you to use the setMute now. In my codepen, setMute is just a workaround. In the future, this workaround will no longer be needed.

@disoul
Copy link
Collaborator

disoul commented Jul 15, 2020

This issue has been fixed in v4.0.0

We deleted the setMute function and user-mute-updated event, you can check out the release note here: https://agoraio-community.github.io/AgoraWebSDK-NG/docs/en/release_note#compatibility-changess

@disoul disoul closed this as completed Jul 15, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants