m0_37545770
yaoyuanloo1
采纳率100%
2018-11-17 02:24 阅读 2.4k
已采纳

webrtc 原生的js怎么调用AEC 消除回音模块

40

//获取音视频.
function getUserMedia() {
try {
navigator.getUserMedia({
'audio' : true,
'video' : pVideo
}, onUserMediaSuccess, onUserMediaError);
} catch (e) {
try {
navigator.getUserMedia("video,audio", onUserMediaSuccess, onUserMediaError);
} catch (e) {
alert(e.message);
console.log(e);
}
}
}

    //加载本地 视频
    function onUserMediaSuccess(stream) {
        console.log("User has granted access to local media.");
        var url = URL.createObjectURL(stream);
        localVideo.style.opacity = 1;
        localVideo.src = url;
        localStream = stream;
        if (initiator)
            maybeStart();
    }

    //创建 PeerConnection
    function createPeerConnection() {

        try {
            pc = new RTCPeerConnection(pc_config);
            pc.onicecandidate = onIceCandidate;
        } catch (e) {
            try {
                var stun_server = "";
                if (pc_config.iceServers.length !== 0) {
                    stun_server = pc_config.iceServers[0].url.replace('stun:', 'STUN ');
                }
                pc = new RTCPeerConnection(stun_server, onIceCandidate);
                isRTCPeerConnection = false;
                console.log("Created webkitPeerConnnection00 with config \"" + stun_server + "\".");
            } catch (e) {
                alert("Failed to create PeerConnection, exception: " + e.message);
                return;
            }
        }
        pc.onconnecting = onSessionConnecting;
        pc.onopen = onSessionOpened;
        pc.onaddstream = onRemoteStreamAdded;
        pc.onremovestream = onRemoteStreamRemoved;
    }

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

2条回答 默认 最新

  • 已采纳
    m0_37545770 yaoyuanloo1 2019-08-08 13:59

    在video标签里面加了个mute属性

    点赞 评论 复制链接分享
  • devmiao devmiao 2018-11-17 15:44

相关推荐