语音通话视频通话界面实现,用于展示出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";
                    }
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值