attachStreams | RTCMultiConnection

This array allows you either manage all your local streams; or attach external (your-own-captured) media streams.

Stop all local streams

connection.attachStreams.forEach(function(localStream) {
    localStream.stop();
});

Attach external streams

connection.attachStreams = [yourExternalStream];

// or
connection.attachStreams.push(yourExternalStream);

Description

parameterdescription
attachStreams It is a JavaScript array
MediaStream webkitMediaStream or native "MediaStream" object

Add external stream in a LIVE session

connection.dontCaptureUserMedia = true;
connection.attachStreams = [yourExternalStream];
connection.addStream({
    audio: true,
    video: true,
    oneway: true
});

Demo

<script src="https://rtcmulticonnection.herokuapp.com/dist/RTCMultiConnection.min.js"></script>
<script src="https://rtcmulticonnection.herokuapp.com/socket.io/socket.io.js"></script>

<script>
var connection = new RTCMultiConnection();

// this line is VERY_important
connection.socketURL = 'https://rtcmulticonnection.herokuapp.com:443/';

// if you want audio+video conferencing
connection.session = {
    audio: true,
    video: true
};

connection.dontCaptureUserMedia = true;
navigator.webkitGetUserMedia({
    video: true,
    audio: true
}, function(yourExternalStream) {
    connection.attachStreams = [yourExternalStream];
    connection.openOrJoin('your-room-id');
}, function(error) {});
</script>