使用
const audioIncoming = document.createElement('audio');
用于通过浏览器进行的呼叫。
静音麦克风的正确方法是什么,而不是从网络传入的音频声音?还是有可能吗?
这是一个完整的代码示例:
const audioProgress = document.createElement('audio');
const audioIncoming = document.createElement('audio');
/*** Define listener for managing calls ***/
var callListeners = {
onCallProgressing: function(call) {
audioProgress.src = 'style/ringback.wav';
audioProgress.loop = true;
audioProgress.play();
$('div#callLog').append('<div id="stats">Ringing...</div>');
},
onCallEstablished: function(call) {
audioIncoming.srcObject = call.incomingStream;
audioIncoming.play();
audioProgress.pause();
//Report call stats
var callDetails = call.getDetails();
$('div#callLog').append('<div id="stats">Answered at: '+(callDetails.establishedTime && new Date(callDetails.establishedTime))+'</div>');
},
onCallEnded: function(call) {
audioProgress.pause();
audioIncoming.srcObject = null;
$('button').removeClass('incall');
$('input#phoneNumber').removeAttr('disabled');
//Report call stats
var callDetails = call.getDetails();
$('div#callLog').append('<div id="stats">Ended: '+new Date(callDetails.endedTime)+'</div>');
$('div#callLog').append('<div id="stats">Duration (s): '+callDetails.duration+'</div>');
$('div#callLog').append('<div id="stats">End cause: '+call.getEndCause()+'</div>');
if(call.error) {
$('div#callLog').append('<div id="stats">Failure message: '+call.error.message+'</div>');
}
}
}