# I am new to ZoomVideo SDK Web

**URL:** <https://devforum.zoom.us/t/i-am-new-to-zoomvideo-sdk-web/86976>\
**Category:** Web\
**Created:** [April 19, 2023, 11:04am UTC](https://devforum.zoom.us/t/i-am-new-to-zoomvideo-sdk-web/86976 "2023-04-19T11:04:52Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![cynthiafernandes2994](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/cynthiafernandes2994/32/47541_2.png) [@cynthiafernandes2994](https://devforum.zoom.us/u/cynthiafernandes2994)\
**Post date:** [April 19, 2023, 11:04am UTC](https://devforum.zoom.us/t/i-am-new-to-zoomvideo-sdk-web/86976/1 "2023-04-19T11:04:53Z")

</div>

I am trying to setup the call between 2 two different users where in the call to be initiated by the host user only and i am not getting any idea how to initiate the call.

Technologies used  
FrondEnd ReactJS  
[Socket.io](http://Socket.io) for the same session to create  
will be using the ZoomVideo SDK

same session is created but the initiating of the call is bit confusing

Please help me out here with the call initiating.

---

<div class="post-metadata">

**Author:** ![rehema.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/rehema.zoom/32/40323_2.png) [@rehema.zoom](https://devforum.zoom.us/u/rehema.zoom)\
**Post date:** [April 21, 2023, 2:25pm UTC](https://devforum.zoom.us/t/i-am-new-to-zoomvideo-sdk-web/86976/3 "2023-04-21T14:25:10Z")

</div>

Hi @cynthiafernandes2994 ,

I want to make sure I’m understanding your needs correctly; you’re able to initiate a session, but unable to join the session (initiate the call). Is this correct?

Thanks,  
Rehema

---

<div class="post-metadata">

**Author:** ![cynthiafernandes2994](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/cynthiafernandes2994/32/47541_2.png) [@cynthiafernandes2994](https://devforum.zoom.us/u/cynthiafernandes2994)\
**Post date:** [April 23, 2023, 2:45pm UTC](https://devforum.zoom.us/t/i-am-new-to-zoomvideo-sdk-web/86976/4 "2023-04-23T14:45:33Z")

</div>

Hi @rehema.zoom

I able to join the call but the problem here is i am not able to put functional video button(the video is not switching on even after starting the button)

Code  
import ZoomVideo from “@zoom1234/videosdk”;  
import { generateSessionToken } from “…/config/signature”;  
import { Button, Tooltip } from “antd”  
import React, { useEffect, useState, useCallback } from ‘react’;  
import {  
AudioOutlined,  
AudioMutedOutlined,  
VideoCameraAddOutlined,  
VideoCameraOutlined,  
WechatOutlined,  
} from “@ant-design/icons”

// window.ZoomVideo = ZoomVideo  
export default function ZoomVideoSample(socket) {  
const [videoStarted, setVideoStarted] = useState(false)  
const [audioStarted, setAudioStarted] = useState(false)  
const [isMuted, setIsMuted] = useState(false)  
const [isChat, setIsChat] = useState(false)  
const [isSAB, setIsSAB] = useState(false)  
const [mediaStreamVideo, setMediaStreamVideo] = useState(‘’)  
console.log(socket);

```
const zmClient = ZoomVideo.createClient();
const sessionConfig = {
    sdkKey: 'redacted',
    sdkSecret: 'redacted',
    topic: 'Call handle',
    password: '123',
    name: 'XYZ',
    sessionKey: '',
    user_identity: '',
    role: 0
};

// console.log('zmClient1:', zmClient);
let mediaStream
const sessionToken = generateSessionToken(
    sessionConfig.sdkKey,
    sessionConfig.sdkSecret,
    sessionConfig.topic,
    sessionConfig.password,
    sessionConfig.sessionKey,
    sessionConfig.user_identity,
    sessionConfig.role
);

const createOne = () => {
    // const zmClient = ZoomVideo.createClient();
    zmClient.init('US-en', 'CDN')

    zmClient.join(sessionConfig.topic, sessionToken, sessionConfig.name, sessionConfig.password).then(() => {
        mediaStream = zmClient.getMediaStream()
        // mediaStream.startVideo()
        setMediaStreamVideo(mediaStream = zmClient.getMediaStream())
        console.log('YES', mediaStream);

    }).catch((error) => {
        console.log(error)
    })
}
const isSupportWebCodecs = () => {
    return typeof window.MediaStreamTrackProcessor === "function"
  }
const startVideoButton = useCallback(async () => {
    console.log("MEDIASTREAM", mediaStreamVideo);
    if (!videoStarted) {
        // if (typeof (window) !== 'undefined') {

            if (mediaStreamVideo.isRenderSelfViewWithVideoElement()) {
                setIsSAB(false)
                mediaStreamVideo.startVideo({ videoElement: document.querySelector('#my-self-view-video') }).then(() => {
                    document.querySelector('#my-self-view-video').style.display = 'block'
                }).catch((error) => {
                    console.log(error)
                })
            } else {
                setIsSAB(true)
                mediaStreamVideo.startVideo().then(() => {
                    mediaStreamVideo.renderVideo(document.querySelector('#my-self-view-canvas'), zmClient.getCurrentUserInfo().userId, 1920, 1080, 0, 0, 2).then(() => {
                        document.querySelector('#my-self-view-canvas').style.display = 'block'
                    }).catch((error) => {
                        console.log(error)
                    })
                }).catch((error) => {
                    console.log(error)
                })
            }
        // }
        setVideoStarted(true)
    }
    else {
        setVideoStarted(false)
        console.log("MEDIASTREAM", zmClient.getCurrentUserInfo());
        await mediaStreamVideo.stopVideo()
        if (isSAB) {
            mediaStreamVideo.stopRenderVideo(
                document.querySelector("#self-view-canvas"),
                zmClient.getCurrentUserInfo().userId
            )
        }
        
    }

}, [mediaStreamVideo, videoStarted, zmClient, isSAB])

const startAudioButton = useCallback(async () => {
    if (audioStarted) {
        if (isMuted) {
            await mediaStreamVideo.unmuteAudio()
            setIsMuted(false)
        } else {
            await mediaStreamVideo.muteAudio()
            setIsMuted(true)
        }
    } else {
        await mediaStreamVideo.startAudio()
        setAudioStarted(true)
    }
}, [mediaStreamVideo, audioStarted, isMuted])

const startChatButton = useCallback(async () => {
    if (isChat) {
        const chat = client.getChatClient()
    } 
}, [zmClient, setIsChat])

useEffect(() => {
    createOne();
}, [socket]);
return <div>
    {isSAB ? (
        <canvas id="self-view-canvas" width="1920" height="1080"></canvas>
    ) : (
        <video id="self-view-video" width="1920" height="1080"></video>
    )}
      {!isSupportWebCodecs() ? (
    <canvas id="share-canvas" width="1920" height="1080"></canvas>
  ) : (
    <video id="share-video" width="1920" height="1080"></video>
  )}
    {/* <canvas id="participant-videos-canvas" height="1080" width="1920"></canvas> */}
    <div className="video-footer">
        <Tooltip title={`${videoStarted ? "Stop Camera" : "Start Camera"}`}>
            <Button
                className="camera-button"
                icon={
                    videoStarted ? (
                        <VideoCameraOutlined />
                    ) : (
                        <VideoCameraAddOutlined />
                    )
                }
                shape="circle"
                size="large"
                onClick={startVideoButton}
            />
        </Tooltip>

        <Tooltip
            title={`${audioStarted ? (isMuted ? "unmute" : "mute") : "Start Audio"
                }`}
        >
            <Button
                className="camera-button"
                icon={
                    // audioStarted ? (
                    isMuted ? (
                        <AudioMutedOutlined />
                    ) : (
                        <AudioOutlined />
                    )
                    // ) : (
                    // <input type="icon-headset" />
                    // )
                }
                shape="circle"
                size="large"
                onClick={startAudioButton}
            />
        </Tooltip>

        <Tooltip
            title={`${isChat ? "Chat" :""
                }`}
        >
            <Button
                className="camera-button"
                icon={

                    <WechatOutlined />

                }
                shape="circle"
                size="large"
                onClick={startChatButton}
            />
        </Tooltip>
    </div>
</div>

```

}

---

<div class="post-metadata">

**Author:** ![cynthiafernandes2994](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/cynthiafernandes2994/32/47541_2.png) [@cynthiafernandes2994](https://devforum.zoom.us/u/cynthiafernandes2994)\
**Post date:** [April 23, 2023, 2:47pm UTC](https://devforum.zoom.us/t/i-am-new-to-zoomvideo-sdk-web/86976/5 "2023-04-23T14:47:12Z")

</div>

![Capture](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/a/3/a395e3cf59b9e76c263fea908c1fbc9c0dbfb096.png)

---

<div class="post-metadata">

**Author:** ![cynthiafernandes2994](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/cynthiafernandes2994/32/47541_2.png) [@cynthiafernandes2994](https://devforum.zoom.us/u/cynthiafernandes2994)\
**Post date:** [April 24, 2023, 2:02pm UTC](https://devforum.zoom.us/t/i-am-new-to-zoomvideo-sdk-web/86976/6 "2023-04-24T14:02:51Z")

</div>

Hi @rehema.zoom

Hoping you could help me with an issue I’m facing in the turning on the video. I have tried putting the video component in the separate file … still i could not find any solution.

---

<div class="post-metadata">

**Author:** ![rehema.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/rehema.zoom/32/40323_2.png) [@rehema.zoom](https://devforum.zoom.us/u/rehema.zoom)\
**Post date:** [April 24, 2023, 2:46pm UTC](https://devforum.zoom.us/t/i-am-new-to-zoomvideo-sdk-web/86976/7 "2023-04-24T14:46:40Z")

</div>

Hi @cynthiafernandes2994 ,

When trying to start video with your button, are you getting a pop-up to allow camera access on your browser? The error ‘camera is closed’ could be related to browser permissions being defaulted to ‘do not allow access’.

Thanks,  
Rehema

---

<div class="post-metadata">

**Author:** ![cynthiafernandes2994](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/cynthiafernandes2994/32/47541_2.png) [@cynthiafernandes2994](https://devforum.zoom.us/u/cynthiafernandes2994)\
**Post date:** [April 25, 2023, 5:32am UTC](https://devforum.zoom.us/t/i-am-new-to-zoomvideo-sdk-web/86976/8 "2023-04-25T05:32:44Z")

</div>

Hi @rehema.zoom

I am trying to start the video on the button click and i am not getting any popup to turn on the camera.

---

<div class="post-metadata">

**Author:** ![cynthiafernandes2994](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/cynthiafernandes2994/32/47541_2.png) [@cynthiafernandes2994](https://devforum.zoom.us/u/cynthiafernandes2994)\
**Post date:** [April 25, 2023, 5:35am UTC](https://devforum.zoom.us/t/i-am-new-to-zoomvideo-sdk-web/86976/9 "2023-04-25T05:35:49Z")

</div>

![zoomError](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/1/f/1f052a73531535bd41fd11e40d16d8de17a96d30.png)

---

<div class="post-metadata">

**Author:** ![cynthiafernandes2994](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/cynthiafernandes2994/32/47541_2.png) [@cynthiafernandes2994](https://devforum.zoom.us/u/cynthiafernandes2994)\
**Post date:** [April 25, 2023, 5:36am UTC](https://devforum.zoom.us/t/i-am-new-to-zoomvideo-sdk-web/86976/10 "2023-04-25T05:36:31Z")

</div>

const startVideoButton = useCallback(async () =\> {  
console.log(“MEDIASTREAM”, mediaStreamVideo);  
if (!videoStarted) {  
// if (typeof (window) !== ‘undefined’) {

```
        if (mediaStreamVideo.isRenderSelfViewWithVideoElement()) {
            setIsSAB(false)
            mediaStreamVideo.startVideo({ videoElement: document.querySelector('#my-self-view-video') }).then(() => {
                document.querySelector('#my-self-view-video').style.display = 'block'
            }).catch((error) => {
                console.log(error)
            })
        } else {
            setIsSAB(true)
            mediaStreamVideo.startVideo().then(() => {
                mediaStreamVideo.renderVideo(document.querySelector('#my-self-view-canvas'), zmClient.getCurrentUserInfo().userId, 1920, 1080, 0, 0, 2).then(() => {
                    document.querySelector('#my-self-view-canvas').style.display = 'block'
                }).catch((error) => {
                    console.log(error)
                })
            }).catch((error) => {
                console.log(error)
            })
        }
        // }
        setVideoStarted(true)
    }
    else {
        setVideoStarted(false)
        console.log("MEDIASTREAM", zmClient.getCurrentUserInfo());
        await mediaStreamVideo.stopVideo()
        if (isSAB) {
            mediaStreamVideo.stopRenderVideo(
                document.querySelector("#self-view-canvas"),
                zmClient.getCurrentUserInfo().userId
            )
        }

    }

}, [mediaStreamVideo, videoStarted, zmClient, isSAB])

```

---

<div class="post-metadata">

**Author:** ![rehema.zoom](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/rehema.zoom/32/40323_2.png) [@rehema.zoom](https://devforum.zoom.us/u/rehema.zoom)\
**Post date:** [April 25, 2023, 12:16pm UTC](https://devforum.zoom.us/t/i-am-new-to-zoomvideo-sdk-web/86976/11 "2023-04-25T12:16:57Z")

</div>

HI @cynthiafernandes2994 ,

I’ve tested with the code snippet you provided and am not running into the same issue. For extra clarity, could you try running the [sample application](https://github.com/zoom/videosdk-web-sample) in the same browser you’re currently using and see if you get the same error?

Also, can you try resetting your permissions for audio and video access, just in case? There should be an information symbol at the start of the URL for your application (I’m assuming you’re using Chrome based on the screenshots), and you can click it to do so.

Thanks,  
Rehema

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex016/uploads/zoomdeveloper/original/3X/6/1/614bdd549b610bbaa46ff934617683a02bdaa03c.png) [@system](https://devforum.zoom.us/u/system)\
**Post date:** [May 25, 2023, 10:17pm UTC](https://devforum.zoom.us/t/i-am-new-to-zoomvideo-sdk-web/86976/12 "2023-05-25T22:17:12Z")

</div>

Closed on May 25, 2023, 10:17pm UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
