Skip to content

Commit f2c68d0

Browse files
authored
Updates to video conferencing sample (#340)
* full-screen feature for video conferencing sample * ability to set video res for video-conferencing sample via 'videores' query param; better config options * quickblox-multiparty-video-conferencing-client-0.2.1.min.js
1 parent af86e55 commit f2c68d0

File tree

9 files changed

+130
-40
lines changed

9 files changed

+130
-40
lines changed
1.18 KB
Loading

samples/video_conferencing/index.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ <h5 class="col-md-12 col-sm-12 col-xs-12 push">Add more user (select to add):</h
207207
<script src="js/video/soundmeter.js"></script>
208208
<script src="js/helpers.js"></script>
209209
<script src="js/connection.js"></script>
210+
<script src="js/config/apps.js"></script>
210211
<script src="js/config/main.js"></script>
211212
<script src="js/messages.js"></script>
212213
<script src="js/ui_helpers.js"></script>
@@ -218,7 +219,7 @@ <h5 class="col-md-12 col-sm-12 col-xs-12 push">Add more user (select to add):</h
218219
<script src="libs/spin.min.js"></script>
219220
<script src="libs/jquery.blockUI.js"></script>
220221
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/webrtc-adapter/5.0.1/adapter.min.js" ></script>
221-
<script src="libs/quickblox-multiparty-video-conferencing-client-0.2.0.min.js"></script>
222+
<script src="libs/quickblox-multiparty-video-conferencing-client-0.2.1.min.js"></script>
222223
<script src="js/video/core.js"></script>
223224
<script src="js/video/ui_helpers.js"></script>
224225

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
var DEMO_APPS = {
2+
"qa": {
3+
endpoints: {
4+
api: "api.quickblox.com",
5+
chat: "chat.quickblox.com"
6+
},
7+
credentials: {
8+
'appId': 56252,
9+
'authKey': 'yPJfas45qY3jbgq',
10+
'authSecret': 'qTFM-eN4vN8rmAw'
11+
},
12+
demoChatDialogId: ""
13+
},
14+
"VideoRecordingDemoApp1": {
15+
endpoints: {
16+
api: "apirc.quickblox.com",
17+
chat: "chatrc.quickblox.com"
18+
},
19+
credentials: {
20+
'appId': 67897,
21+
'authKey': 'JEMb6GKcrrzOBTP',
22+
'authSecret': 'h2UxCPHf7Oqk8Pw'
23+
},
24+
demoChatDialogId: "5afa823c12685f101adaf628"
25+
},
26+
"VideoRecordingDemoApp2": {
27+
endpoints: {
28+
api: "apirc.quickblox.com",
29+
chat: "chatrc.quickblox.com"
30+
},
31+
credentials: {
32+
'appId': 67898,
33+
'authKey': 'kAgbhA9Q99UtygB',
34+
'authSecret': 'DxgzQyyOgaYaLJL'
35+
},
36+
demoChatDialogId: "5afa825512685f101adaf62a"
37+
}
38+
}
Lines changed: 33 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,43 @@
1-
var QBCONFIG = {
2-
endpoints: {
3-
api: "api.quickblox.com", // set custom API endpoint
4-
chat: "chat.quickblox.com" // set custom Chat endpoint
5-
},
6-
debug: {
7-
mode: 1,
8-
file: null
9-
}
10-
};
11-
12-
var QBApp = {
13-
'prod': {
14-
'appId': 56252,
15-
'authKey': 'yPJfas45qY3jbgq',
16-
'authSecret': 'qTFM-eN4vN8rmAw'
17-
}
18-
};
19-
1+
// Sample version
2+
//
203
var SAMPLE_VER = 78;
214
$('.j-version').text('v.' + SAMPLE_VER);
225

23-
var QBAppCreds = QBApp.prod;
24-
25-
6+
// WebRTC server endpoint
7+
//
268
var MULTIPARTY_SERVER = getQueryVar('server');
279
if(!MULTIPARTY_SERVER){
2810
var noServerError = "The 'server' query parameter is not set. You need to provide it in order to run the sample. Multi-conference server is available only for Enterprise plans. Please refer to https://quickblox.com/developers/EnterpriseFeatures for more information and contacts."
2911
alert(noServerError);
3012
throw noServerError;
31-
3213
}
3314
console.info("server var: ", MULTIPARTY_SERVER);
15+
16+
// Demo app credentials
17+
//
18+
var QB_APP = getQueryVar('app');
19+
console.info("demo app: ", QB_APP);
20+
var appCreds;
21+
if(!QB_APP){
22+
appCreds = DEMO_APPS.qa;
23+
}else{
24+
appCreds = DEMO_APPS[QB_APP];
25+
}
26+
27+
var QBCONFIG = {
28+
endpoints: appCreds.endpoints,
29+
debug: {
30+
mode: 1,
31+
file: null
32+
}
33+
};
34+
35+
var QBAppCreds = appCreds.credentials;
36+
37+
var DEMO_DIALOG_ID = appCreds.demoChatDialogId;
38+
39+
var VIDEO_RESOLUTION = getQueryVar('videores');
40+
if(!VIDEO_RESOLUTION){
41+
VIDEO_RESOLUTION = "lowres";
42+
}
43+
console.info("video resolution: ", VIDEO_RESOLUTION);

samples/video_conferencing/js/messages.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
var currentDialog = {};
1+
var currentDialog;
22
var opponentId;
33

44
var dialogsMessages = [];

samples/video_conferencing/js/video/core.js

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ function initialise(){
1616
iceServers: [{urls: "stun:stun.l.google.com:19302"},
1717
{urls: "turn:turn.quickblox.com:3478?transport=udp", username: "quickblox", credential: "baccb97ba2d92d71e26eb9886da5f1e0"},
1818
{urls: "turn:turn.quickblox.com:3478?transport=tcp", username: "quickblox", credential: "baccb97ba2d92d71e26eb9886da5f1e0"}],
19-
video: {quality: 'lowres', frameRate: 25}
19+
video: {quality: VIDEO_RESOLUTION}
2020
};
2121
client = new QBVideoConferencingClient(config);
2222

@@ -274,6 +274,11 @@ function clickJoinOrLeaveVideoChat(isStopByInitiator, isStopByBadNetwork) {
274274

275275
// Start
276276
} else {
277+
if(!currentDialog){
278+
bootbox.alert("Please create a chat dialog first");
279+
return;
280+
}
281+
277282
$('#call_btn').prop('disabled', "disabled");
278283

279284
// Init Video engine
@@ -302,7 +307,7 @@ function clickJoinOrLeaveVideoChat(isStopByInitiator, isStopByBadNetwork) {
302307
addFeedView(currentUser.id, true);
303308

304309
// join video chat
305-
var roomIdToJoin = dialogIdForVideoRecording();
310+
var roomIdToJoin = currentDialog._id;
306311

307312
client.join(roomIdToJoin, currentUser.id, isAudioCallOnly, {
308313
success: function() {
@@ -462,15 +467,30 @@ function toggleMute() {
462467
console.info("Now is muted=" + muted);
463468
}
464469

470+
function toggleFullscreen(){
471+
var mediaScreen = document.getElementById("myvideo");
472+
enableFullScreen(mediaScreen);
473+
}
474+
465475
function toggleRemoteMute(event) {
466476
var userId = parseInt(event.target.id.replace("mute_", ""));
467477
var muted = client.toggleRemoteAudioMute(userId);
468478
$("#" + event.target.id).html(muted ? "Unmute" : "Mute");
469479
console.info("Now remote is muted=" + muted);
470480
}
471481

482+
function toggleRemoteFullscreen(event){
483+
console.log(event);
484+
console.log(event.target.id);
485+
var userId = parseInt(event.target.id.replace("fullscreen_", ""));
486+
console.log(userId);
487+
var mediaScreen = document.getElementById("remotevideo"+userId);
488+
console.log(mediaScreen)
489+
enableFullScreen(mediaScreen);
490+
}
491+
472492
function actionsForTheInitiator() {
473-
client.listOnlineParticipants(dialogIdForVideoRecording(), {
493+
client.listOnlineParticipants(currentDialog._id, {
474494
success: function(participants){
475495
console.log("listOnlineParticipants, participants: ", participants);
476496
if (!participants) {
@@ -592,15 +612,26 @@ function stopAllICEFailedTimers(){
592612
iceFailedTimers = [];
593613
}
594614

595-
596-
function dialogIdForVideoRecording(){
597-
if(currentDialog.name == "RecordingDemoRoom"){
598-
roomIdToJoin = "5ab234c01cc0c00e62c96960";
599-
}else{
600-
roomIdToJoin = currentDialog._id;
615+
function enableFullScreen(mediaScreen){
616+
if (mediaScreen.requestFullscreen) {
617+
if (document.fullScreenElement) {
618+
document.cancelFullScreen();
619+
} else {
620+
mediaScreen.requestFullscreen();
621+
}
622+
} else if (mediaScreen.mozRequestFullScreen) {
623+
if (document.mozFullScreenElement) {
624+
document.mozCancelFullScreen();
625+
} else {
626+
mediaScreen.mozRequestFullScreen();
627+
}
628+
} else if (mediaScreen.webkitRequestFullscreen) {
629+
if (document.webkitFullscreenElement) {
630+
document.webkitCancelFullScreen();
631+
} else {
632+
mediaScreen.webkitRequestFullscreen();
633+
}
601634
}
602-
603-
return roomIdToJoin;
604635
}
605636

606637
// function ICE_RESTART_LOCAL_TEST(){

samples/video_conferencing/js/video/ui_helpers.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,16 @@ function prepareLocalVideoUI() {
7676

7777
$('#videolocal').append('<video class="rounded centered" id="myvideo" width="100%" height="100%" autoplay muted="muted"/>');
7878

79+
// Add a 'video full screen' button
80+
$('#videolocal').append('<button class="btn btn-default btn-xs" id="fullscreen" style="position: absolute; top: 0px; right: 0px; margin-top: 28px; margin-right: 20px; background-color: #ccc;"> <img src="images/icon-full-mode-on.png" /></button>');
81+
$('#fullscreen').click(toggleFullscreen);
82+
7983
// Add a 'mute' button
8084
$('#videolocal').append('<button class="btn btn-warning btn-xs" id="mute" style="position: absolute; bottom: 0px; left: 0px; margin: 15px;">Mute</button>');
8185
$('#mute').click(toggleMute);
8286
// $('#mute').click(ICE_RESTART_LOCAL_TEST);
87+
//
88+
//icon-full-mode-on.png
8389
}
8490

8591
function prepareRemoteVideoUI(userId) {
@@ -89,13 +95,17 @@ function prepareRemoteVideoUI(userId) {
8995
}
9096
if(!isAudioCallOnly){
9197
$('#videoremote' + userId).append(
92-
'<span class="label label-primary hide" id="curres' + userId + '" style="position: absolute; top: 17px; right: 0px; margin: 15px;"></span>' +
98+
'<span class="label label-primary hide" id="curres' + userId + '" style="position: absolute; top: 17px; left: 10px; margin: 15px;"></span>' +
9399
'<span class="label label-info hide" id="curbitrate' + userId + '" style="position: absolute; bottom: 0px; right: 0px; margin: 15px;"></span>'
94100
);
95101
}
96102
//
97103
$('#videoremote' + userId).append('<meter max="1" value="0" id="audioStreamVolume' + userId + '" style="position: absolute; bottom: 10px; left: 0px; right: 0px; margin: 34px; color: #0f9d58; width: 65%;"></meter>');
98104

105+
// Add a 'video full screen' button
106+
$('#videoremote' + userId).append('<button class="btn btn-default btn-xs" id="fullscreen_' + userId + '" style="position: absolute; top: 0px; right: 0px; margin-top: 28px; margin-right: 20px; background-color: #ccc;"> <img src="images/icon-full-mode-on.png" id="fullscreen_' + userId + '" /></button>');
107+
$('#fullscreen_' + userId).click(toggleRemoteFullscreen);
108+
99109
// Add a 'mute' button
100110
$('#videoremote' + userId).append('<button class="btn btn-warning btn-xs" id="mute_' + userId + '" style="position: absolute; bottom: 0px; left: 0px; margin: 15px;">Mute</button>');
101111
$('#mute_' + userId).click(toggleRemoteMute);

samples/video_conferencing/libs/quickblox-multiparty-video-conferencing-client-0.2.0.min.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

samples/video_conferencing/libs/quickblox-multiparty-video-conferencing-client-0.2.1.min.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)