question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

UnbindVideoElement

See original GitHub issue

Hello,

Am trying to get the following effect.

  1. Video streams are already “bind” successfully to small thumb nails
  2. When user press on the thumb nails, video stream is first “unbind” from the smaller thumb nail and then “bind” to a larger sized element.

Am unable to get both unbindVideoElement and bindVideoElement working in stage (2).

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
ileccesecommented, Nov 30, 2020

cool, thanks for your help.

I think it would be helpful to have unbindVideoElement remove the srcObject, or at least to make it clear in the documentation that unbindVideoElement won’t remove the video stream from the video element, because I think most people would assume it just does the opposite of bindVideoElement

1reaction
ileccesecommented, Nov 30, 2020

Interesting, so you’re saying all unbindVideoElement is supposed to do is trigger a videoTileDidUpdate with boundVideoElement = null and that if I want to remove the video stream from that video element I need to do that myself?

I have video tiles setup very similar to the components library’s RemoteTile, where each video tile takes a tileId as props and has a useEffect to unbind/bind to that tileId when it’s updated:

useEffect(() => {
    if (meetingSession && props.tileId) {
      if (meetingSession.audioVideo.getVideoTile(props.tileId)) {
        logger.info(`App: binding tileId ${props.tileId} to ${props.tileName}`);
        meetingSession.audioVideo.bindVideoElement(props.tileId, ref.current);
      }
    }
    return () => {
      if (meetingSession && props.tileId) {
        const tile = meetingSession.audioVideo.getVideoTile(props.tileId);
        if (tile) {
          logger.info(`App: unbinding tileId ${props.tileId} from ${props.tileName}`);
          meetingSession.audioVideo.unbindVideoElement(props.tileId);
        }
      }
    };
  }, [props.tileId, props.tileName, meetingSession, logger, ref]);

The problem I was running into is that we are implementing a “pin user to top tile” feature and expected that we could simply swap the order of the tileIds in state and when each video tile received a new tileId, it would unbind the old tileId and bind the new tileId. this worked fine when the tiles that were being swapped both had active video streams, but if one stream was inactive (the participant had their camera off), the video element which previously had the active stream would still show it. Based on your explanation, this is because unbindVideoElement does not remove the old srcObject and the new inactive tileId didn’t have a new srcObject to replace the old srcObject Replacing unbindVideoElement with removing the srcObject seems work as expected:

useEffect(() => {
    if (meetingSession && props.tileId) {
      if (meetingSession.audioVideo.getVideoTile(props.tileId)) {
        logger.info(`App: binding tileId ${props.tileId} to ${props.tileName}`);
        meetingSession.audioVideo.bindVideoElement(props.tileId, ref.current);
      }
    }
    return () => {
      if (meetingSession && props.tileId) {
        const tile = meetingSession.audioVideo.getVideoTile(props.tileId);
        if (tile) {
          logger.info(`App: unbinding tileId ${props.tileId} from ${props.tileName}`);
          // meetingSession.audioVideo.unbindVideoElement(props.tileId);
          ref.current.srcObject = null;
        }
      }
    };
  }, [props.tileId, props.tileName, meetingSession, logger, ref]);
Read more comments on GitHub >

github_iconTop Results From Across the Web

AudioVideoFacade | amazon-chime-sdk-js
Gets an AnalyserNode from the current audio input. This node can be used to generate the display for a mic indicator. null is...
Read more >
javascript - Amazon chime SDK - Video not stopping when ...
When on a video call and the stopLocalVideoTile() method is called (by clicking a button). I have also tried using removeLocalVideoTile() ...
Read more >
amazon-chime-sdk-js | Yarn - Package Manager
Clean up the HTML video element bounded to VideoTileState using unbindVideoElement API to fix Safari memory leak. If you do not intend to...
Read more >
What is the Amazon Chime SDK?
You can choose to implement some or all of the available media modalities (audio, video, and screen share) for a single rate. Messaging,...
Read more >
react createRef TypeScript Examples - ProgramCreek.com
... bindVideoElement, unbindVideoElement, nameplatePosition = 'bottom', } = props; const containerRef = createRef<HTMLDivElement>(); const videoRef = React.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found