This message was deleted.
# helpdesk
s
This message was deleted.
f
And I tried to unpublish/publish audio track 3 times, But it's not getting Remote Track published event
@dry-elephant-14928 Can you help for this issue?
@polite-kilobyte-67570
This issue is the urgent for me. Can you help how to fix this issue?
p
hi @flat-ability-87405 please provide some reproduction, best in the form of a working example app or at least an extensive code snippet. Without some more context it’s hard to say what’s triggering your issue.
f
Copy code
public async stopAudioTrack() {
    const audioTrackPublication = this.participant?.getTrack(Track.Source.Microphone);

    if (audioTrackPublication && audioTrackPublication.audioTrack) {
      await this.participant?.unpublishTrack(audioTrackPublication.audioTrack.mediaStreamTrack);
      this.audioPublication = undefined;
    }
  }
This is unpublish current audio track. After call this, I tried to publish new track. And I tried this way for 2 times
Copy code
await this.stopAudioTrack();
await this.participant?.publishTrack(audioTrack, {
            name: generateRandomString(6),
            source: Track.Source.Microphone,
          });
@polite-kilobyte-67570 Please check above codes
p
thanks, can you also provide the parts where you listen to the publish/unpublish events and how the unpublish/publish sequence get’s triggered?
f
Yes.
After connect to the room, there is no issue. But when I try to publish/unpublish, it's not getting the event sometimes
@polite-kilobyte-67570
p
thanks for the info, are you using livekit cloud or a self-deployed instance?
f
self deployed instance
p
if the issue is urgent for you, would it work, as a workaround, to mute the track instead?
f
This is for noise reduction
When the user enable/disable noise reduction, It's trying to unpublish/publish the audio track.
So at that time, it's broken to get the event track published after get track unpublished
p
aha! In that case the API you want to use is
localAudioTrack.restartTrack({noiseSuppression: true/false})
there’s no need to unpublish/republish the track.
f
Restart track?
Sorry. we attached our own audio track with noise reduction
So I used
replaceTrack
. But
replaceTrack
has the issue with noise reduction
p
is this an external noise reduction that you’re applying?
f
Yes right
p
what kind of issues are you seeing with the
replaceTrack
approach?
f
So I hope you help me why it's not getting
TrackPublished
event sometimes when the user try to publish/unpublish
d
@flat-ability-87405 please remember that this is a public support channel where folks are helping you at no cost. Some etiquette that's worth called out: please avoid tagging individuals unless you are already in a conversation with them. and do not expect immediate help even if the issue is urgent to you. thank you for understanding
2
another tip: you are more likely to get a high quality answer if you are making it easy for others to understand what you mean. I do not recommend posting screenshots with scribbles or ChatGPT dialogue.. we will not be able to read them
2
p
@flat-ability-87405 this PR fixes the timing issues of unpublish/publish https://github.com/livekit/client-sdk-js/pull/541