# The video does not appear when the user comes to the page

**URL:** <https://devforum.zoom.us/t/the-video-does-not-appear-when-the-user-comes-to-the-page/62056>\
**Category:** Web\
**Created:** [December 30, 2021, 4:50pm UTC](https://devforum.zoom.us/t/the-video-does-not-appear-when-the-user-comes-to-the-page/62056 "2021-12-30T16:50:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![reactdev](https://avatars.discourse-cdn.com/v4/letter/r/85f322/32.png) [@reactdev](https://devforum.zoom.us/u/reactdev)\
**Post date:** [December 30, 2021, 4:50pm UTC](https://devforum.zoom.us/t/the-video-does-not-appear-when-the-user-comes-to-the-page/62056/1 "2021-12-30T16:50:58Z")

</div>

I try start livestream video on open page, follow doc for setup and create token, init, join, start video. Session is started, users are join on session, but video doesn’t show. I try with canvas and video tags.

on first render get error in console:  
canvas is falsy  
on click start button get error:  
You must pass a `<video>` element to start video capture for Chromium browser, Android browser, and Chrome without SharedArrayBuffer support.

zoom/videosdk:1.1.7,

```auto
import React, {
    FC,
    useCallback,
    useContext,
    useEffect,
    useRef,
    useState,
    useMemo
} from 'react';
import ZoomContext from 'core/components/ZoomClientContext';
import { KJUR } from 'jsrsasign';
import { ChatClient, MediaStream } from "./index-types";
import ZoomVideo, { ConnectionState } from "@zoom/videosdk";
import style from './index.module.scss';
import LivestreamUI from './LivestreamUI/livestreamui';

export const LivestreamVideoComp = (props: any) => {
    const client: any = useContext(ZoomContext);
    const canvasRef = useRef<HTMLCanvasElement | null>(null);
    const videoRef = useRef<HTMLVideoElement | null>(null);

    useEffect(() => {
        const init = async () => {
            const token = generateVideoToken(
                "test",
                "password"
            );
            console.log('token', token);
            await client.init();
            try {
                await client.join(
                    "test",
                    token,
                    "userIdd",
                    "password",
                )
                const stream = await client.getMediaStream();
                await stream.startVideo();
                 changeHandler()

            } catch (e: any) {
                setIsLoading(false);
                console.log(e.reason);
            }
        };
        init();
    }, []);

    const changeHandler = async () => {
        client.on('peer-video-state-change', async (payload: { action: any; userId: any; }) => {
            console.log('payload', payload);
            const {
                action,
                userId
            } = payload;
            if (action === 'Start') {
                await stream.renderVideo(videoRef.current, userId, 1280, 720, 0, 0, 3);
            } else if (action === 'Stop') {
                await stream.stopRenderVideo();
            }
        })
    }

    const stop = async () => {
        const stream = await client.getMediaStream();
        await stream.stopVideo();
        await stream.renderVideo();
    }

    const start = async () => {
        const stream = await client.getMediaStream();
        await stream.startVideo();
        changeHandler()
    }

    function generateVideoToken(topic: any, password = "") {
        let signature = "";
        // try {
        const iat = Math.round(new Date().getTime() / 1000);
        const exp = iat + 60 * 60 * 2;

        // Header
        const oHeader = { alg: "HS256", typ: "JWT" };
        // Payload
        const oPayload = {
            app_key: sdkKey,
            iat,
            exp,
            tpc: topic,
            pwd: password,
            user_identity: userIdd,
            version: 1
        };
        // Sign JWT
        const sHeader = JSON.stringify(oHeader);
        const sPayload = JSON.stringify(oPayload);
        signature = KJUR.jws.JWS.sign("HS256", sHeader, sPayload, sdkSecret);
        return signature;
    }

    return (
                <div className={style.videoBox}>
                    <div style={{ display: 'flex', justifyContent: 'center', position: 'absolute', zIndex: 4 }}>
                        <button style={{ width: 100, height: 30 }} onClick={() => stop()}>stop</button>
                        <button style={{ width: 100, height: 30 }} onClick={() => start()}>start</button>
                    </div>
                    <video
                        className={style.videoCanvas}
                        //id="video-canvas"
                        // width="1600"
                        // height="900"
                        ref={videoRef}
                    />
                    {/* <canvas
                        id={SELF_VIDEO_ID}
                        className={style.previewVideo}
                        ref={canvasRef}
                        width="1600"
                        height="900"
                    /> */}
                </div>
    );
};

```

- Device: Macbook Pro M1
- OS: [e.g. macOS 11]
- Browser: Chrome, Firefox
- Browser Version 96.0.4664.110 (Official Build) (arm64)

---

<div class="post-metadata">

**Author:** ![vic.yang](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/vic.yang/32/24656_2.png) [@vic.yang](https://devforum.zoom.us/u/vic.yang)\
**Post date:** [January 4, 2022, 1:49am UTC](https://devforum.zoom.us/t/the-video-does-not-appear-when-the-user-comes-to-the-page/62056/2 "2022-01-04T01:49:18Z")

</div>

Hey @reactdev

Thanks for your feedback.

Could you provide the result of following expression?

```javascript
console.log(window.crossOriginIsolated)

```

If the result is false, maybe you are not using the Cross-Origin Isolating, refer to [Improve Performance in Chrome](https://marketplace.zoom.us/docs/sdk/overview/improve-performance) for detail. Or you can follow the prompts on the console, pass a VideoElement parameter when invoking the `media.startVideo` method.

Thanks  
Vic

---

<div class="post-metadata">

**Author:** ![reactdev](https://avatars.discourse-cdn.com/v4/letter/r/85f322/32.png) [@reactdev](https://devforum.zoom.us/u/reactdev)\
**Post date:** [January 11, 2022, 8:10am UTC](https://devforum.zoom.us/t/the-video-does-not-appear-when-the-user-comes-to-the-page/62056/3 "2022-01-11T08:10:37Z")

</div>

Thanks Vic,

can we put HTMLCanvasElement into media.startVideo?  
When i start video don’t see video in current, from second tab i see video of first tab.  
Chrome don’t ask me for camera access and i can’t strat video from chrome, when start video from firefox video is seen in chrome.

```auto
    useEffect(() => {
        const init = async () => {
            const token = generateVideoToken(
                "test",
                "password"
            );

            console.log('token', token);
            setTok(token);
            await client.init();
            try {
                await client.join(
                    "test",
                    token,
                    "userIdd",
                    "password",
                )
                //await client.makeHost(userIdd);
                const videoElement = await document.querySelector(
                    `#${SELF_VIDEO_ID}`,
                ) as HTMLVideoElement;
                const stream = await client.getMediaStream();
                await stream.startVideo({ videoElement });
                await renderHandler()
            } catch (e: any) {
                console.log(e.reason);
            }
        };
        init();
    }, []);

    const renderHandler = async () => {
        const videoElement = document.querySelector(
            `#${SELF_VIDEO_ID}`,
        ) as HTMLVideoElement;
        const stream = await client.getMediaStream();
        await client.on('peer-video-state-change', async (payload: any) => {
            const {
                action,
                userId
            } = payload;
            if (action === 'Start') {
                await stream.renderVideo(videoElement, userId, 1280, 720, 0, 0, 3);
            } else if (action === 'Stop') {
                await stream.stopRenderVideo(videoElement);
            }
        })
    }

    const stop = async () => {
        const stream = await client.getMediaStream();
        await stream.stopVideo();
        await renderHandler();
    }

    const start = async () => {
        const videoElement = document.querySelector(
            `#${SELF_VIDEO_ID}`,
        ) as HTMLVideoElement;
        const stream = await client.getMediaStream();
        await stream.startVideo({ videoElement });
        await renderHandler();
    }

                        <canvas
                        id={SELF_VIDEO_ID}
                        className={style.previewVideo}
                        width="1600"
                        height="900"
                    />

```

---

<div class="post-metadata">

**Author:** ![vic.yang](https://sea2.discourse-cdn.com/flex016/user_avatar/devforum.zoom.us/vic.yang/32/24656_2.png) [@vic.yang](https://devforum.zoom.us/u/vic.yang)\
**Post date:** [January 11, 2022, 9:57am UTC](https://devforum.zoom.us/t/the-video-does-not-appear-when-the-user-comes-to-the-page/62056/4 "2022-01-11T09:57:25Z")

</div>

Hey @reactdev

If the value of the expression `window.crossOriginIsolated` is false, an `VideoElement` is required.  
Maybe our [react-sample-app](https://github.com/zoom/sample-app-videosdk/tree/master/react-demo) is a useful reference for your cases.

Thanks  
Vic

---

<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:** [February 10, 2022, 8:09pm UTC](https://devforum.zoom.us/t/the-video-does-not-appear-when-the-user-comes-to-the-page/62056/6 "2022-02-10T20:09:30Z")

</div>

Closed on February 10, 2022, 8:09pm UTC

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