DEV Community

Discussion on: How to add an overlay to your web video chat

Collapse
manprajapat profile image
MANISH PRAJAPATI
Thread Thread
philnash profile image
Phil Nash Author

Ah, that application!

OK, so what have you tried?

Thread Thread
manprajapat profile image
MANISH PRAJAPATI

I took css from glitch.

Code is update here : github.com/manprajapat/twilio-vide...
I have added

<div class="videos">
    <div id="video-container live">
        <p className="name">Manish Prajapati</p>
        <video ref={videoRef} autoPlay={true} />
    </div>
</div>

css

.name {
  position: absolute;
  top: 8px;
  left: 0;
  margin: 0;
  padding: 0.5em 0.5em 0.5em 2em;
  background: rgba(242, 47, 70, 0.8);
  color: #fff;
  font-size: 16px;
  line-height: 1;
}

.name::after {
  content: "";
  height: 0;
  width: 0;
  position: absolute;
  top: 0;
  right: -2em;
  border: 1em solid rgba(242, 47, 70, 0.8);
  border-right-color: transparent;
  border-bottom-color: transparent;
}

#video-container {
  position: relative;
}

#video-container::before {
  content: "";
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 140px;
  height: 32px;
  background: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAARgAAABACAYAAADBJGiiAAAACXBIWXMAABYlAAAWJQFJUiTwAAARdElEQVR4nO2dD2iU9R/Hv3N2ap11rEmnMnFytT+STZljdZFjxDEwbakUTMRflKFCnNEfQrNYsxEW5Ir+gGg/GMsUqZkJcr+UE6fGtWoqui0PFxvLi9mx1sVMsvvxfnw+13ffPc/t9txzc9PPC8bd7vn3/fv+fj6f7/d5nqx4PC6MyMrKcgshcoUQLiHEZMOdGIa5lflbCNEvhLgcj8cjhjqiCkxWVhYEpVAIMZWbDsMwKXJFCNERj8f75d2HCIxutRRyiTIMY5EO2ZqZRF9YXBiGsYFCXUs0NIGR3CKGYZh0KdQ1JWHBsLgwDGMnmqZM0s0ZDugyDGMnU6Etk/SpaIZhGLvJnaSvc2EYhrEb1yReRMcwTIaYPIlLlmGYTMECwzBMxmCBYRgmY4xp/CUvL89RXV3t9ng8ObNnz86ZMmWKQ94+MDAQu3z5cqy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DGVi5lhmBS5IlsuxDCBSWzIysIDk3PxlgW7X5LPMMxNAdbQQVAuy1ZLAiHE/wGxFb/ft+SpVwAAAABJRU5ErkJggg==');
  background-size: cover;
}

#video-container video {
  max-width: 100%;
}

#video-container::before,
.name {
  opacity: 0;
  transition: opacity 0.5s;
}

#video-container.live::before,
.live .name {
  opacity: 1;
}

.videos {
  display: flex;
}
Thread Thread
philnash profile image
Phil Nash Author

Thanks for linking to your repo of this. I can see that you're getting the location using the geolocation API, but you're never rendering it, so it's not going to appear on top of the video (or anywhere on the page). You're logging it to the console, but you need to consider how you're going to actually render the data first, then work on styling it.

Thread Thread
manprajapat profile image
MANISH PRAJAPATI

Yes, But for now, I have added only static element there

<p className="name">Manish Prajapati</p>

I need to show this name on video frame

I will work on geolocation after styling.

Thread Thread
philnash profile image
Phil Nash Author

Ah, I see.

Ok, you have two problems (and then another one coming down the line).

First, you have the wrong id on your video container. It's currently:

        <div id="video-container live">

ids can't have spaces and that live should be a class. There is a second problem you have in the JSX where the surrounding <div> has a class and not a className.

But, there's one further thing to watch out for. You will have multiple <Participant> components on the page, so you should not use ids for that. You could change video-container to a className and then change the CSS from #video-container to .video-container.

So, your participant JSX should be:

    <div className="participant">
      <h3>{participant.identity}</h3> 
      <div className="videos">
        <div className="video-container live">
          <p className="name">Manish Prajapati</p>
          <video ref={videoRef} autoPlay={true} />
        </div>
      </div>
      <audio ref={audioRef} autoPlay={true} muted={true} />
    </div>

And the CSS should be:

.video-container {
  position: relative;
}

.video-container::before {
  content: "";
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 140px;
  height: 32px;
  background: url('data:image/png;');
  background-size: cover;
}

.video-container video {
  max-width: 100%;
}

.video-container::before,
.name {
  opacity: 0;
  transition: opacity 0.5s;
}

.video-container.live::before,
.live .name {
  opacity: 1;
}

Try that and see how you get on.

Thread Thread
manprajapat profile image
MANISH PRAJAPATI

Ahhhhhhhhhh!!! my bad, that I missed the id, I am thinking it was a class. Yes, it works!!
Thanks Dear :) Happy coding.