Skip to content
Snippets Groups Projects
Commit 1ddcc700 authored by Rodrigo Nascimento's avatar Rodrigo Nascimento
Browse files

Stop streaming if connection be disconnected

parent b9aa7790
No related branches found
No related tags found
No related merge requests found
......@@ -34,6 +34,20 @@ webrtc.start = function (isCaller) {
webrtc.onRemoteUrl(URL.createObjectURL(evt.stream));
};
webrtc.pc.oniceconnectionstatechange = function(evt) {
console.log('oniceconnectionstatechange', arguments)
if (evt.srcElement.iceConnectionState == 'disconnected') {
webrtc.pc.getLocalStreams().forEach(function(stream) {
stream.stop();
webrtc.onSelfUrl();
});
webrtc.pc.getRemoteStreams().forEach(function(stream) {
stream.stop();
webrtc.onRemoteUrl();
});
}
}
// get the local stream, show it in the local video element and send it
navigator.getUserMedia({ "audio": true, "video": true }, function (stream) {
webrtc.onSelfUrl(URL.createObjectURL(stream));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment