Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejs
function pausePlayback() {
    if (preRecordedAudioElement && !preRecordedAudioElement.paused) {
        preRecordedAudioElement.pause();

        // Re-enable the user's microphone
        if (userStream) {
            userStream.getAudioTracks().forEach(track => {
                track.enabled = true;
            });
        }
    }
}

// Function to mute the user's microphone during playback
function muteMicrophone() {
    if (userStream) {
        userStream.getAudioTracks().forEach(track => {
            track.enabled = false;
        });
    }
}

// Example of how to trigger the playback during the call
document.getElementById('playButton').addEventListener('click', function() {
    // This would need to be adapted based on your specific scenario
    // For example, you might initiate a call when the button is clicked
    // or trigger playback during an ongoing call
});

// Example of how to pause the playback during the call
document.getElementById('pauseButton').addEventListener('click', pausePlayback);

// Example of how to mute the microphone during the call
document.getElementById('muteButton').addEventListener('click', muteMicrophone);