Skip to content
This repository was archived by the owner on Dec 6, 2023. It is now read-only.
This repository was archived by the owner on Dec 6, 2023. It is now read-only.

Video track accessed by multiple <AgoraVideoPlayer /> components: track.stop() / track.close() does not turn off camera light #43

@sunweiyang

Description

@sunweiyang

For my company's web app, we need to have the local camera's video accessible by both our main video chat interface and our video chat settings popup modal (see screenshot below).

image (19)

To try to accomplish this, we create tracks in our parent component using

const useMicrophoneAndCameraTracks = createMicrophoneAndCameraTracks(
  { AEC: true, ANS: true },
  { optimizationMode: "motion" }
);

and

const { ready, tracks } = useMicrophoneAndCameraTracks();

From this, our video track is tracks[1], which is used in both our main video chat interface's component and our video chat settings popup modal's <AgoraVideoPlayer /> component (passed in as props).

However, the problem is that we then fail to turn off the camera (and camera light) after we dismount the parent component:

  useEffect(() => {
    ...
    return () => {
        for (const track of tracks) {
          track.stop();
          track.close();
        }
    }, []);

We do confirm that the camera and camera light does turn off if we only use the track in only one single <AgoraVideoPlayer />

How can we ensure that the light turns off when the parent component is dismounted? Or if this is not the right approach, what should we do instead?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions