Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Right side video not coming #17

Open
akashgreninja opened this issue Jan 31, 2023 · 3 comments
Open

Right side video not coming #17

akashgreninja opened this issue Jan 31, 2023 · 3 comments

Comments

@akashgreninja
Copy link

I have tested a lot with even myvideo but the right side video does not seem to appear I have tried everything
I also wrote a js statement to see if the uservideo exists which comes out to be true

I am not able to view myvideo as well right side
it only appears if I refresh the page

@praveenrambalu
Copy link

Yes I have also tested even with your code and I followed along with your tutorials I have created from scratch both are same but rightside video is not working

@DaveSimoes
Copy link

DaveSimoes commented Aug 7, 2023

Hi Everyone.
It´s work for me :
Please try run "nodemon index.js" on root file of project , start again and write your name, copy ID and Paste on ID to Call.

I really hope have helped. ...

@xlgabriel
Copy link

Hi there! I noticed you're experiencing issues with the video ref not updating properly in React 18. This is a common issue due to the new concurrent features in React 18, which can affect how updates to the DOM are handled, especially for media streams. I've encountered a similar problem and found a solution that worked well for me. Here's how you can approach it:

The key is to use useEffect to handle the assignment of the stream to your video element (myVideo and userVideo in your case) whenever the stream changes. This ensures that any change in the stream is promptly reflected in the video element.

Here's an example based on the original code from this repo:

useEffect(() => {
  if (myVideo.current && stream) {
    myVideo.current.srcObject = stream;
  }
}, [myVideo, stream]);

useEffect(() => {
  if (userVideo.current && stream) {
    userVideo.current.srcObject = stream;
  }
}, [userVideo, stream]);

This code will effectively update the srcObject of your video elements whenever the stream changes or the ref to the video element is set.

Explanation:
useEffect and Dependencies: The useEffect hook runs whenever its dependencies (myVideo, userVideo, stream) change. This means whenever you get a new stream or when the video element's ref is initialized, useEffect re-runs, updating the srcObject.

Handling Stream Changes: By managing the stream with useEffect, you ensure that the video element always has the latest stream assigned to its srcObject. This is crucial for applications handling real-time media streams.

Implementing this change should help in ensuring that updates to your stream are consistently reflected in your video elements, addressing the issue you're facing in React 18.

Hope this helps! Let me know if you have any more questions or issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants