Uncaught TypeError: Cannot read property 'getVideoTracks' of undefined

hi

I’m tracking errors using full-scale monitoring.
But I get the following error:
Under what circumstances do such an error occur?

camStatusChanged = () => {
    localUser.setVideoActive(!localUser.isVideoActive());
    localUser.getStreamManager().publishVideo(localUser.isVideoActive());
    this.sendSignalUserChanged({ isVideoActive: localUser.isVideoActive() });
    this.setState({ localUser: localUser },()=>{this.props.VideoActions.setLocalUser(this.state.localUser);});
}

Can you point us to the offending line?

Where the errors is thrown?

Activation and deactivation of the cam is implemented using openvidu-browser.

As you can see from the source below, the video status values ​​will change according to the instructions.

localUser.isVideoActive() => true or false

camStatusChanged = () => {
    localUser.setVideoActive(!localUser.isVideoActive());
    localUser.getStreamManager().publishVideo(localUser.isVideoActive());
    this.sendSignalUserChanged({ isVideoActive: localUser.isVideoActive() });
    this.setState({ localUser: localUser },()=>{this.props.VideoActions.setLocalUser(this.state.localUser);});
}

openvidu-browser publishVideo in progress
“Uncaught TypeError: Cannot read property’getVideoTracks’of undefined”

I am getting these errors. Is there a solution?

That error means that you are calling method Publisher.pusblishVideo BEFORE the Publisher object has been successfully initialized. Try using the promisified version of OpenVidu.initPublisherAsync instead: OpenVidu | OpenVidu Browser - v2.17.0. Calling the method publishAudio or publishVideo on the Publisher object returned by that promise will work fine. And of course make sure you are properly initializing the Publisher with a video track or an audio track if you want to call publishVideo or publishAudio respectively.

1 Like