toggleAudio method

bool toggleAudio()

Implementation

bool toggleAudio() {
  if (stream != null) {
    final audioTrack = stream!.getAudioTracks()[0];
    final bool audioEnabled = audioTrack.enabled = !audioTrack.enabled;
    this.audioEnabled = audioEnabled;

    sendMessage('audio-toggle', {
      'userId': userId,
      'audioEnabled': audioEnabled,
    });
    emit('audio-toggle', null, {
      'userId': userId,
      'audioEnabled': audioEnabled,
    });
    return audioEnabled;
  }
  return false;
}