当我从另一方收到onaddstream事件时,如何确定MediaStream只有音频,没有视频?
换句话说,我可以知道MediaStream对象只有音频,没有视频吗?
答案 0 :(得分:3)
peer.onaddstream = function (event) {
var stream = event.stream;
if (stream.getAudioTracks().length) alert('Peer has audio stream.');
if (stream.getVideoTracks().length) alert('Peer has video stream.');
};