Skip to content

Commit

Permalink
Added: rtcmulticonnection-v3@3.2.86 Fixed #84 Added "connection.reset…
Browse files Browse the repository at this point in the history
…Track"

“connection.resetTrack” works only in Firefox, to reset last audio or
video track.

If you replaced a video track; you can reset to old one.

Added “removeStream” ugly-hack for Firefox.

Now “muteType” is passed over “onmute” and “unmuteType” is passed over
“onunmute”.

Now firing “onstreamended” for Firefox screen as well.

You can override “connection.getScreenConstraints” to set random id,
and then you’ll be able to capture multiple screens and share in
parallel.
  • Loading branch information
muaz-khan committed Jan 17, 2016
1 parent 8593159 commit dbe1e2c
Show file tree
Hide file tree
Showing 18 changed files with 614 additions and 154 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
node_modules
bower_components

make-tar.sh

*.tar.gz
lib-cov

Expand Down
2 changes: 2 additions & 0 deletions .npmignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
node_modules
bower_components

make-tar.sh

*.tar.gz
lib-cov
v2.2.2
Expand Down
70 changes: 68 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ All files from `/dist` directory are available on CDN: `https://cdn.webrtc-exper
<script src="https://cdn.webrtc-experiment.com:443/rmc3.min.js"></script>

<!-- or specific version -->
<script src="/~https://github.com/muaz-khan/RTCMultiConnection/releases/download/3.2.84/rmc3.min.js"></script>
<script src="/~https://github.com/muaz-khan/RTCMultiConnection/releases/download/3.2.86/rmc3.min.js"></script>
```

If you're sharing files, you also need to link:
Expand All @@ -76,7 +76,7 @@ If you're sharing files, you also need to link:
<script src="https://cdn.webrtc-experiment.com:443/rmc3.fbr.min.js"></script>

<!-- or specific version -->
<script src="/~https://github.com/muaz-khan/RTCMultiConnection/releases/download/3.2.84/rmc3.fbr.min.js"></script>
<script src="/~https://github.com/muaz-khan/RTCMultiConnection/releases/download/3.2.86/rmc3.fbr.min.js"></script>
```

> You can link multiple files from `dev` directory. Order doesn't matters.
Expand Down Expand Up @@ -248,6 +248,38 @@ var videoTrack = yourVideoStream.getVideoTracks()[0];
connection.replaceTrack(videoTrack, remoteUserId);
```

### `resetTrack`

If you replaced a video or audio track, RTCMultiConnection keeps record of old track, and allows you move-back-to previous track:

```javascript
connection.resetTrack(null, true);
```

It takes following arguments:

1. `[Array of user-ids]` or `"single-user-id"` or `null`
2. Is video track (boolean): Either `true` or `false`. `null` means replace all last tracks.

```javascript
// with single user
connection.resetTrack('specific-userid', true);

// with multiple users
connection.resetTrack(['first-user', 'second-user'], true);

// NULL means all users
connection.resetTrack(null, true);

// reset only audio
connection.resetTrack(null, false);

// to reset all last-tracks (both audio and video)
connection.resetTrack();
```

> Means that you can reset all tracks that are replaced recently.
### `onUserStatusChanged`

This even allows you show online/offline statuses of the user:
Expand Down Expand Up @@ -989,6 +1021,40 @@ connection.multiPeersHandler.onPeerStateChanged = function(state) {
};
```

## How to mute/unmute?

You can compare `muteType` for `onmute` event; and `unmuteType` for `onunmute` event.

```javascript
connection.onmute = function(e) {
if (!e.mediaElement) {
return;
}

if (e.muteType === 'both' || e.muteType === 'video') {
e.mediaElement.src = null;
e.mediaElement.pause();
e.mediaElement.poster = e.snapshot || 'https://cdn.webrtc-experiment.com/images/muted.png';
} else if (e.muteType === 'audio') {
e.mediaElement.muted = true;
}
};

connection.onunmute = function(e) {
if (!e.mediaElement) {
return;
}

if (e.unmuteType === 'both' || e.unmuteType === 'video') {
e.mediaElement.poster = null;
e.mediaElement.src = URL.createObjectURL(e.stream);
e.mediaElement.play();
} else if (e.unmuteType === 'audio') {
e.mediaElement.muted = false;
}
};
```

## RTCMultiConnection v2.2.2 Demos

| Experiment Name | Demo | Source Code |
Expand Down
Loading

0 comments on commit dbe1e2c

Please sign in to comment.