Pause/Resume Call
Control the conversation flow by pausing and resuming the microphone and audio processing.
Pause Call
Temporarily pause the conversation to stop listening and speaking:
import { Micdrop } from '@micdrop/client'
// Pause the call - stops microphone and mutes speakerMicdrop.pause()
console.log('Call paused:', Micdrop.isPaused) // trueWhen paused:
- βΈοΈ Microphone stops recording
- βΈοΈ No audio is sent to the server
- βΈοΈ Incoming audio is muted
- βΈοΈ Send event to server to stop processing
- β Voice activity detection stays enabled
- β WebSocket connection remains active
Resume Call
Resume the conversation to continue listening and speaking:
// Resume the call - restarts microphone and unmutes speakerMicdrop.resume()
console.log('Call paused:', Micdrop.isPaused) // falseconsole.log('Now listening:', Micdrop.isListening) // trueWhen resumed:
- β Microphone starts recording again
- β Audio processing continues
- β Incoming audio plays normally
State Monitoring
Monitor pause/resume state changes:
Micdrop.on('StateChange', (state) => { if (state.isPaused) { console.log('π Call is paused') // Update UI to show paused state updateStatus('Paused - Click to resume') } else if (state.isListening) { console.log('π€ Call resumed - Listening...') // Update UI to show active state updateStatus('Listening for your voice') }})UI Integration
Create pause/resume controls in your interface:
// Button handler for pause/resume togglefunction togglePause() { if (Micdrop.isPaused) { Micdrop.resume() document.getElementById('pauseBtn').textContent = 'Pause' } else { Micdrop.pause() document.getElementById('pauseBtn').textContent = 'Resume' }}React example:
import { useMicdropState } from '@micdrop/react'
function CallControls() { const state = useMicdropState()
return ( <button onClick={state.isPaused ? Micdrop.resume : Micdrop.pause}> {state.isPaused ? 'βΆοΈ Resume' : 'βΈοΈ Pause'} </button> )}