# How to turn on and off video and audio

```javascript
let cameraState = true;
let micState = true;
```

To turn on and off video, use the `toggleVideo` function.

```javascript
function toggleVideo(){
	if(cameraState){
		WTSDK.Participant.disableVideo();
		cameraState = false;
		const video = document.getElementById('vide_control');
		video.classList.remove('vcam_on');
		video.classList.add('vcam_off');
	}else {
		WTSDK.Participant.enableVideo();
		cameraState = true;
		const video = document.getElementById('vide_control');
		video.classList.remove('vcam_off');
		video.classList.add('vcam_on');
	}
}
```

There is a similar function available for working with audio (`toggleAudio`).

```javascript
function toggleAudio() {
	if(micState){
		WTSDK.Participant.disableAudio();
		micState = false;
		const video = document.getElementById('audio_control');
		video.classList.remove('mic_on');
		video.classList.add('mic_off');
	}else {
		WTSDK.Participant.enableAudio();
		micState = true;
		const video = document.getElementById('audio_control');
		video.classList.remove('mic_off');
		video.classList.add('mic_on');
	}
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://documentation.sceenic.co/watch-together-sdk/sscale-confluence-tutorials/web/sample-application/how-to-turn-on-and-off-video-and-audio.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
