Skip to content

Commit

Permalink
check local stream nullity
Browse files Browse the repository at this point in the history
  • Loading branch information
burak-58 committed Dec 22, 2024
1 parent 334b471 commit fc6e684
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
13 changes: 10 additions & 3 deletions react/src/pages/AntMedia.js
Original file line number Diff line number Diff line change
Expand Up @@ -475,7 +475,6 @@ function AntMedia(props) {
const [isNoSreamExist, setIsNoSreamExist] = React.useState(false);



const {t} = useTranslation();

const theme = useTheme();
Expand Down Expand Up @@ -2834,7 +2833,9 @@ function AntMedia(props) {
// When we first open home page, React will call this function and local stream is null at that time.
// So, we need to catch the error.
try {
webRTCAdaptor?.switchVideoCameraCapture(publishStreamId, value);
webRTCAdaptor?.switchVideoCameraCapture(publishStreamId, value, () => {
console.log("Camera selection callback");
});
} catch (e) {
console.log("Local stream is not ready yet.");
}
Expand Down Expand Up @@ -2948,7 +2949,13 @@ function AntMedia(props) {
return true;
}
// if the camera is turned on and the video track is muted, then there is a problem with the camera
return !webRTCAdaptor?.mediaManager?.localStream?.getVideoTracks()[0].muted;
let localStream = webRTCAdaptor?.mediaManager?.localStream;
if(localStream == null || webRTCAdaptor?.mediaManager?.localStream.getVideoTracks()[0].muted) {
//camera is not working properly
return false;
}

return true;
}

const getTrackStats = React.useCallback(() => { // eslint-disable-line no-unused-vars
Expand Down
3 changes: 1 addition & 2 deletions react/src/pages/WaitingRoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@ function WaitingRoom(props) {
}, [conference.initialized]);

function joinRoom(e) {
e.preventDefault();

let isVideoTrackHealthy = conference?.checkVideoTrackHealth();
if (!isVideoTrackHealthy) {
enqueueSnackbar(
Expand All @@ -95,6 +93,7 @@ function WaitingRoom(props) {
return;
}
if (conference.localVideo === null && conference.isPlayOnly === false) {
e.preventDefault();
enqueueSnackbar(
{
message: t(
Expand Down

0 comments on commit fc6e684

Please sign in to comment.