首页 > 其他分享 >语音通话视频通话界面实现,用于展示出webRTC实时聊天媒体流,CSS实现效果

语音通话视频通话界面实现,用于展示出webRTC实时聊天媒体流,CSS实现效果

时间:2023-02-13 22:46:02浏览次数:44  
标签:display 50% 60px height 通话 remoteStream remoteVideo webRTC CSS

在开发webRTC的语音和视频通话功能的时候,需要展示出媒体流,这样就需要一个下面这样的效果

 

 

html部分代码

        <!--视频-->
        <div class="remoteVideoMask">
            <img id="remoteVideoMaskLogo" :src="noticeAvatar" />
            <video id="chatRtc" controls  autoplay></video>
            <a class="refuse" @click="callClose()">挂断</a>
        </div>
        <!--视频-->

样式代码

.remoteVideoMask{
    width: 100%;
    height: 100%;
    position: fixed;
    z-index: 9999999;
    left: 0px;
    top: 0px;
    background: #333;
}
.remoteVideoMask #chatRtc{
    width: 100%;
    height: 100%
}
.remoteVideoMask .refuse{
    bottom: 60px;
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    display: inline-block;
    width: 60px;
    height: 60px;
    color: #fff;
    background-color: #f56c6c;
    border-color: #f56c6c;
    text-align: center;
    line-height: 60px;
    border-radius: 50%;
}
#remoteVideoMaskLogo{
    width: 60px;
    height: 60px;
    position: absolute;
    border-radius: 5px;
    z-index: 9;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
}

JS部分代码

                    console.log(remoteStream);
                    var videoTracks = remoteStream.getVideoTracks();
                    var audioTracks = remoteStream.getAudioTracks();

                    var remoteVideo = document.getElementById("chatRtc");
                    var logo=document.getElementById("remoteVideoMaskLogo");
                    remoteVideo.srcObject = remoteStream;
                    remoteVideo.autoplay = true;
                    remoteVideo.play();
                    //视频流
                    if (videoTracks.length > 0) {
                        logo.style.display = "none";
                        remoteVideo.style.display = "block";
                    }else if (audioTracks.length > 0) {
                        //音频流
                        remoteVideo.style.display = "none";
                        logo.style.display = "block";
                    }

 

标签:display,50%,60px,height,通话,remoteStream,remoteVideo,webRTC,CSS
From: https://www.cnblogs.com/taoshihan/p/17118111.html

相关文章

  • CSS 实现水平和垂直居中的三种方法
    绝对定位+负边距:使用绝对定位并设置左右负边距和上下负边距,就可以实现水平和垂直居中的效果。.center-element{position:absolute;top:50%;left:50%;......
  • css知识点
    1.css盒模型:盒子的组成:内容content,内边距padding,边框border,外边距margin盒模型的类型:标准盒模型:margin+padding+border+contentIE盒模型:margin+content(包含了bo......
  • 打开MASA Blazor的正确姿势3.1:HTML和CSS基础
    一、HTML和CSS关系HTML元素定义网页的文档结构,CSS定义网页的排版样式。这句话不好理解,通过导航栏案例领会一下(以下案例非常精彩):1、导航栏的HTML文档结构<ul><li><a......
  • css悬浮动画
    1.Grow-Shadow /*Grow-Shadow*/.hvr-grow-shadow{display:inline-block;vertical-align:middle;-webkit-transform:perspective(1px)translateZ(0);......
  • CSS畅想 | 有一天,我遇到了一个奇特的路灯,眼里一下子有了光
    灵感来源我对系列这个词的执着来源于大学时代看小说的习惯,看书爱看系列文。于是我也喜欢把自己写的文章分分类,比如「工作小记」、「经验总结」等。当然了它们学会自己成长之......
  • css积累-1
    提问1如何设置div居中回答style="width:95%;min-height:400px;display:flex;"提问2如何播放MP4回答<videoid='video'style='width:95%;min-height:400px......
  • CSS Animation
    为什么要引入CSSAnimation视觉动物怎么能止步于看静态的?人性是第一生产力关键是解放了Javascript如何完成一个简单的动画使用@keyframes结合animation来完成举......
  • 网站在线客服系统实时语音视频聊天实战开发,利用peerjs vue.js实现webRTC网页音视频客
    webRTC机制和peerjs库的介绍在其他博客中已经有了很多介绍,这里我直接搬运过来一、webrtc回顾WebRTC(WebReal-TimeCommunication)即:网页即时通信。简单点讲,它可以实现浏......
  • 学习css的第五天~
    文本样式属性名属性属性值注释文本颜色color英文关键词、十六进制、rgb方法 文本行高line-height像素值控制行与行之间的距离对齐方式text-align......
  • 学习css的第四天~
    字体样式属性名属性属性值注释字体类型font-family字体名称英文放前面,中文放后面字体大小font-size像素值 字体风格font-stylenormal:默认italic......