如何确定webrtc媒体流只有音频?

时间:2013-12-14 06:27:43

标签: webrtc

当我从另一方收到onaddstream事件时,如何确定MediaStream只有音频,没有视频?

换句话说,我可以知道MediaStream对象只有音频,没有视频吗?

1 个答案:

答案 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.');
};