在easyrtc api中静音麦克风(node.js)

时间:2017-05-11 17:36:36

标签: javascript jquery node.js socket.io easyrtc

如何通过javascript中的onclick功能将麦克风静音。 我这样做

audio.js

async void OnClick_Start(object sender, EventArgs ea)
{
    txtTest.Text = "Starting";
    await System.Threading.Tasks.Task.Delay(1000);
    RunOnUiThread(() =>   { txtTest.Text = "1000"; }
    await System.Threading.Tasks.Task.Delay(1000);
    RunOnUiThread(() =>   { txtTest.Text = "2000"; }
    await System.Threading.Tasks.Task.Delay(1000);
    RunOnUiThread(() =>   { txtTest.Text = "3000"; }
    await System.Threading.Tasks.Task.Delay(1000);
    RunOnUiThread(() =>   { txtTest.Text = "4000";}
}

livestreaming.html

function muteAudio(){
    easyrtc.enableAudio(false);
}

但这不起作用。有人可以帮帮我吗。

1 个答案:

答案 0 :(得分:1)

.enableAudio()将设置是否传输音频。如果要将本地或远程媒体流静音,只需使用音频或视频元素音量属性即可。

这是一个例子。



var audio = document.querySelector('audio');
var button = document.querySelector('button');

audio.volume = 0.5;

button.addEventListener('click', function(e) {
	audio.volume = (audio.volume === 0) ? .5 : 0;
  this.textContent = (this.textContent === 'Mute Audio') ? 'Unmute Audio' : 'Mute Audio'; 
})

<audio src="https://upload.wikimedia.org/wikipedia/commons/4/41/Ascending_fifths.wav" autoplay loop>
  Your browser does not support the <code>audio</code> element.
</audio>

<button>Mute Audio</button>
&#13;
&#13;
&#13;