274 lines
8.7 KiB
HTML
274 lines
8.7 KiB
HTML
<!-- Demo version: 2019.01.14 -->
|
|
|
|
<!DOCTYPE html>
|
|
<html lang="en" dir="ltr">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<title>Vuejs Video Conferencing using RTCMultiConnection</title>
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0">
|
|
<link rel="shortcut icon" href="/include/videocall/demos/logo.png">
|
|
<link rel="stylesheet" href="/include/videocall/demos/stylesheet.css">
|
|
<script src="/include/videocall/demos/menu.js"></script>
|
|
</head>
|
|
<body>
|
|
<header>
|
|
<a class="logo" href="/include/videocall/demos/"><img src="/include/videocall/demos/logo.png" alt="RTCMultiConnection"></a>
|
|
<a href="/include/videocall/demos/" class="menu-explorer">Menu<img src="/include/videocall/demos/menu-icon.png" alt="Menu"></a>
|
|
<nav>
|
|
<li>
|
|
<a href="/include/videocall/demos/">Home</a>
|
|
</li>
|
|
<li>
|
|
<a href="https://www.rtcmulticonnection.org/docs/getting-started/">Getting Started</a>
|
|
</li>
|
|
<li>
|
|
<a href="https://www.rtcmulticonnection.org/FAQ/">FAQ</a>
|
|
</li>
|
|
<li>
|
|
<a href="https://www.youtube.com/playlist?list=PLPRQUXAnRydKdyun-vjKPMrySoow2N4tl">YouTube</a>
|
|
</li>
|
|
<li>
|
|
<a href="https://rtcmulticonnection.herokuapp.com/include/videocall/demos/">Demos</a>
|
|
</li>
|
|
<li>
|
|
<a href="https://github.com/muaz-khan/RTCMultiConnection/wiki">Wiki</a>
|
|
</li>
|
|
<li>
|
|
<a href="https://github.com/muaz-khan/RTCMultiConnection">Github</a>
|
|
</li>
|
|
</nav>
|
|
</header>
|
|
|
|
<h1>
|
|
Vuejs Video Conferencing using RTCMultiConnection
|
|
<p class="no-mobile">
|
|
Multi-user (many-to-many) video chat using mesh networking model.
|
|
</p>
|
|
</h1>
|
|
|
|
<section class="make-center">
|
|
<input type="text" id="room-id" value="abcdef" autocorrect=off autocapitalize=off size=20>
|
|
<button id="open-room">Open Room</button>
|
|
<button id="join-room">Join Room</button>
|
|
<button id="open-or-join-room">Auto Open Or Join Room</button>
|
|
|
|
<div id="vue-app">
|
|
<todo-item
|
|
v-for="item in videosList"
|
|
v-bind:todo="item"
|
|
v-bind:key="item.id">
|
|
</todo-item>
|
|
</div>
|
|
|
|
<div id="room-urls" style="text-align: center;display: none;background: #F1EDED;margin: 15px -10px;border: 1px solid rgb(189, 189, 189);border-left: 0;border-right: 0;"></div>
|
|
</section>
|
|
|
|
<script src="/include/videocall/dist/RTCMultiConnection.min.js"></script>
|
|
<script src="/include/videocall/demos/node_modules/webrtc-adapter/out/adapter.js"></script>
|
|
<script src="/include/videocall/demos/socket.io.js"></script>
|
|
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
|
|
<script>
|
|
// ......................................................
|
|
// .......................UI Code........................
|
|
// ......................................................
|
|
document.getElementById('open-room').onclick = function() {
|
|
disableInputButtons();
|
|
connection.open(document.getElementById('room-id').value, function() {
|
|
showRoomURL(connection.sessionid);
|
|
});
|
|
};
|
|
|
|
document.getElementById('join-room').onclick = function() {
|
|
disableInputButtons();
|
|
connection.join(document.getElementById('room-id').value);
|
|
};
|
|
|
|
document.getElementById('open-or-join-room').onclick = function() {
|
|
disableInputButtons();
|
|
connection.openOrJoin(document.getElementById('room-id').value, function(isRoomExist, roomid) {
|
|
if (isRoomExist === false && connection.isInitiator === true) {
|
|
// if room doesn't exist, it means that current user will create the room
|
|
showRoomURL(roomid);
|
|
}
|
|
});
|
|
};
|
|
|
|
// ......................................................
|
|
// ..................RTCMultiConnection Code.............
|
|
// ......................................................
|
|
|
|
var connection = new RTCMultiConnection();
|
|
|
|
// by default, socket.io server is assumed to be deployed on your own URL
|
|
connection.socketURL = 'https://cs3198.mojohost.com:9001/';
|
|
|
|
// comment-out below line if you do not have your own socket.io server
|
|
// connection.socketURL = 'https://rtcmulticonnection.herokuapp.com:443/';
|
|
|
|
connection.socketMessageEvent = 'video-conference-demo';
|
|
|
|
connection.session = {
|
|
audio: true,
|
|
video: true
|
|
};
|
|
|
|
connection.sdpConstraints.mandatory = {
|
|
OfferToReceiveAudio: true,
|
|
OfferToReceiveVideo: true
|
|
};
|
|
|
|
Vue.component('todo-item', {
|
|
props: ['todo'],
|
|
template: '<video controls autoplay playsinline :srcObject.prop="todo.srcObject" :muted="todo.muted" :id="todo.id"></video>'
|
|
})
|
|
|
|
var vueApp = new Vue({
|
|
el: '#vue-app',
|
|
data: {
|
|
videosList: []
|
|
}
|
|
})
|
|
|
|
connection.autoCreateMediaElement = false;
|
|
connection.onstream = function(event) {
|
|
vueApp.videosList.push({
|
|
id: event.streamid,
|
|
srcObject: event.stream,
|
|
muted: event.type === 'local'
|
|
});
|
|
};
|
|
|
|
connection.onstreamended = function(event) {
|
|
var newList = [];
|
|
vueApp.videosList.forEach(function(item) {
|
|
if(item.id !== event.streamid) {
|
|
newList.push(item);
|
|
}
|
|
});
|
|
vueApp.videosList = newList;
|
|
};
|
|
|
|
// ..................................
|
|
// ALL below scripts are redundant!!!
|
|
// ..................................
|
|
|
|
function disableInputButtons() {
|
|
document.getElementById('room-id').onkeyup();
|
|
|
|
document.getElementById('open-or-join-room').disabled = true;
|
|
document.getElementById('open-room').disabled = true;
|
|
document.getElementById('join-room').disabled = true;
|
|
document.getElementById('room-id').disabled = true;
|
|
}
|
|
|
|
// ......................................................
|
|
// ......................Handling Room-ID................
|
|
// ......................................................
|
|
|
|
function showRoomURL(roomid) {
|
|
var roomHashURL = '#' + roomid;
|
|
var roomQueryStringURL = '?roomid=' + roomid;
|
|
|
|
var html = '<h2>Unique URL for your room:</h2><br>';
|
|
|
|
html += 'Hash URL: <a href="' + roomHashURL + '" target="_blank">' + roomHashURL + '</a>';
|
|
html += '<br>';
|
|
html += 'QueryString URL: <a href="' + roomQueryStringURL + '" target="_blank">' + roomQueryStringURL + '</a>';
|
|
|
|
var roomURLsDiv = document.getElementById('room-urls');
|
|
roomURLsDiv.innerHTML = html;
|
|
|
|
roomURLsDiv.style.display = 'block';
|
|
}
|
|
|
|
(function() {
|
|
var params = {},
|
|
r = /([^&=]+)=?([^&]*)/g;
|
|
|
|
function d(s) {
|
|
return decodeURIComponent(s.replace(/\+/g, ' '));
|
|
}
|
|
var match, search = window.location.search;
|
|
while (match = r.exec(search.substring(1)))
|
|
params[d(match[1])] = d(match[2]);
|
|
window.params = params;
|
|
})();
|
|
|
|
var roomid = '';
|
|
if (localStorage.getItem(connection.socketMessageEvent)) {
|
|
roomid = localStorage.getItem(connection.socketMessageEvent);
|
|
} else {
|
|
roomid = connection.token();
|
|
}
|
|
document.getElementById('room-id').value = roomid;
|
|
document.getElementById('room-id').onkeyup = function() {
|
|
localStorage.setItem(connection.socketMessageEvent, document.getElementById('room-id').value);
|
|
};
|
|
|
|
var hashString = location.hash.replace('#', '');
|
|
if (hashString.length && hashString.indexOf('comment-') == 0) {
|
|
hashString = '';
|
|
}
|
|
|
|
var roomid = params.roomid;
|
|
if (!roomid && hashString.length) {
|
|
roomid = hashString;
|
|
}
|
|
|
|
if (roomid && roomid.length) {
|
|
document.getElementById('room-id').value = roomid;
|
|
localStorage.setItem(connection.socketMessageEvent, roomid);
|
|
|
|
// auto-join-room
|
|
(function reCheckRoomPresence() {
|
|
connection.checkPresence(roomid, function(isRoomExist) {
|
|
if (isRoomExist) {
|
|
connection.join(roomid);
|
|
return;
|
|
}
|
|
|
|
setTimeout(reCheckRoomPresence, 5000);
|
|
});
|
|
})();
|
|
|
|
disableInputButtons();
|
|
}
|
|
|
|
// detect 2G
|
|
if(navigator.connection &&
|
|
navigator.connection.type === 'cellular' &&
|
|
navigator.connection.downlinkMax <= 0.115) {
|
|
alert('2G is not supported. Please use a better internet service.');
|
|
}
|
|
</script>
|
|
|
|
<section>
|
|
<p>
|
|
You can write cordova/ionic/phonegap based <a href="https://www.rtcmulticonnection.org/docs/Write-iOS-Apps/" target="_blank">iOS</a> or <a href="https://www.rtcmulticonnection.org/docs/Write-Android-Apps/" target="_blank">Android</a> apps for this demo as well.
|
|
|
|
You can download <a href="https://webrtcweb.com/cordova-apps/video-conferencing/">an open-sourced cordova app</a> both for iOS and Android as well.
|
|
</p>
|
|
|
|
<p>
|
|
You can run same demo on Safari-11 as well. (both on MacOSX & iOS)
|
|
</p>
|
|
|
|
<p>
|
|
You can install following Android app and join meetings from this demo:
|
|
|
|
<a href="https://play.google.com/store/apps/details?id=rmc3.videoconference" target="_blank">https://play.google.com/store/apps/details?id=rmc3.videoconference</a>
|
|
</p>
|
|
|
|
<p>
|
|
Microsoft Edge is also supported.
|
|
</p>
|
|
</section>
|
|
|
|
<footer>
|
|
<small id="send-message"></small>
|
|
</footer>
|
|
|
|
<script src="https://cdn.webrtc-experiment.com/common.js"></script>
|
|
</body>
|
|
</html>
|