# Publisher.replaceTrack(audioTrack) unmutes audio

**URL:** <https://openvidu.discourse.group/t/publisher-replacetrack-audiotrack-unmutes-audio/3527>\
**Category:** Issues developing apps\
**Tags:** v2\
**Created:** [October 27, 2021, 8:57am UTC](https://openvidu.discourse.group/t/publisher-replacetrack-audiotrack-unmutes-audio/3527 "2021-10-27T08:57:15Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![user2](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/user2/32/1716_2.png) [@user2](https://openvidu.discourse.group/u/user2)\
**Post date:** [October 27, 2021, 8:57am UTC](https://openvidu.discourse.group/t/publisher-replacetrack-audiotrack-unmutes-audio/3527/1 "2021-10-27T08:57:15Z")

</div>

According to version 2.18 release notes, Publisher.replaceTrack misbehaviour is now fixed. I have version 2.20 and I came across the issue of hearing my voice after calling replaceTrack.  
Here is my code:

```auto
function changeMediaStream(audioSource, videoSource, kind) {
    openvidu.getUserMedia({
        audioSource: audioSource, //refering to deviceId of the microphone that is about to replace the 
                                                    //previous one. videoSource will be false when audioSource has value
                                                    // 'kind' will be 'audio'

        videoSource: videoSource, //refering to deviceId of the camera that is about to replace the 
                                                    //previous one. audioSource will be false when videoSource has 
                                                    //value
                                                    // 'kind' will be 'video'

        resolution: window.initializedPublisherProperties.resolution, //resolution with which I've had 
                                                                                                       //initiallized publisher

        frameRate: window.initializedPublisherProperties.frameRate //frameRate with which I've had 
                                                                                                       //initiallized publisher

    }).then(mediaStream => {

        let track;
        if (kind === 'audio') {
            track = mediaStream.getAudioTracks()[0];
        }
        if (kind === 'video') {
            track = mediaStream.getVideoTracks()[0];
        }
     
        publisher.replaceTrack(track).then(() => {
            console.log('track changed successfully')
        }).catch(error => {
            console.error(error)
        })

    }).catch(error => {
        console.error(error)
    })
}

```

Do I do something wrong?  
Thank you in advance

---

<div class="post-metadata">

**Author:** ![pabloFuente](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/pablofuente/32/2536_2.png) [@pabloFuente](https://openvidu.discourse.group/u/pabloFuente)\
**Post date:** [June 23, 2022, 11:34am UTC](https://openvidu.discourse.group/t/publisher-replacetrack-audiotrack-unmutes-audio/3527/2 "2022-06-23T11:34:14Z")

</div>

See commit [openvidu-browser: fix echo when calling Publisher#replaceTrack · OpenVidu/openvidu@17ff910 · GitHub](https://github.com/OpenVidu/openvidu/commit/17ff9105aaf05f435f6247c7fa4d7eaa39daf812)
