多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[TOC] ## MediaStream ***** 一些方法 ``` 流媒体里添加轨:MediaStream.addTrack() 流媒体里删除轨:MediaStream.removeTrack() 在流媒体里获取视频轨:MediaStream.getVideoTracks() 所有音频轨:MediaStream.getAudioTracks() ``` Media事件 ``` MediaStream.onaddtrack MediaStream.onremovetrack MediaStream.onended ``` ## 获取视频约束 创建一个div用来存放获取到的视频约束参数: ``` <div id="constraints" class="output"> </div> ``` 获取该div元素 ``` var divConstraints = document.querySelector('div#constraints'); ``` 在gotMediaStream函数里添加 ``` function gotMediaStream(stream) { vidoeplay.srcObject = stream; var videoTrack = stream.getVideoTracks()[0]; var videoContraints = videoTrack.getSettings(); // 获取video所有的约束 divConstraints.textContent = JSON.stringify(videoContraints, null, 2); return navigator.mediaDevices.enumerateDevices(); } ```