我getUserMedia
用来访问网络摄像头。我有一个功能可以打开和关闭视频,执行以下操作:
var videoTracks = this.stream.getVideoTracks();
if (videoTracks.length === 0) {
trace('No local video available.');
return;
}
trace('Toggling video mute state.');
for (var i = 0; i < videoTracks.length; ++i) {
videoTracks[i].enabled = !videoTracks[i].enabled;
}
trace('Video ' + (videoTracks[0].enabled ? 'unmuted.' : 'muted.'));
当值改变时如何接收事件enabled
?我尝试使用Object.observe
,但它不起作用。