You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
109 lines
2.9 KiB
109 lines
2.9 KiB
/* eslint-disable require-jsdoc */
|
|
|
|
function addViewId(id) {
|
|
if ($('div#spth_win' + id).length === 0) {
|
|
$('div#agora_remote_video').empty();
|
|
$('div#agora_remote_video').append('<div id="' + id + '" style="width:100%;height:100%;display:inline-block;"></div>');
|
|
}
|
|
}
|
|
|
|
function addView(id) {
|
|
if (!$('#' + id)[0]) {
|
|
$('<div/>', {
|
|
id,
|
|
class: 'video-view'
|
|
}).appendTo('#video_grid');
|
|
}
|
|
}
|
|
|
|
function removeView(id) {
|
|
if ($('#' + id)[0]) {
|
|
$('#' + id).remove();
|
|
$('#spth_win').hide();
|
|
rtc.leave();
|
|
rtc = null;
|
|
}
|
|
}
|
|
|
|
// populate camera options
|
|
TRTC.getCameras().then(devices => {
|
|
devices.forEach(device => {
|
|
$('<option/>', {
|
|
value: device.deviceId,
|
|
text: device.label
|
|
}).appendTo('#cameraId');
|
|
});
|
|
});
|
|
|
|
// populate microphone options
|
|
TRTC.getMicrophones().then(devices => {
|
|
devices.forEach(device => {
|
|
$('<option/>', {
|
|
value: device.deviceId,
|
|
text: device.label
|
|
}).appendTo('#microphoneId');
|
|
});
|
|
});
|
|
|
|
function getCameraId() {
|
|
const selector = document.getElementById('cameraId');
|
|
const cameraId = selector[selector.selectedIndex].value;
|
|
return cameraId;
|
|
}
|
|
|
|
function getMicrophoneId() {
|
|
const selector = document.getElementById('microphoneId');
|
|
const microphoneId = selector[selector.selectedIndex].value;
|
|
return microphoneId;
|
|
}
|
|
|
|
// fix jquery touchstart event warn in chrome M76
|
|
jQuery.event.special.touchstart = {
|
|
setup: function (_, ns, handle) {
|
|
if (ns.includes('noPreventDefault')) {
|
|
this.addEventListener('touchstart', handle, {passive: false});
|
|
} else {
|
|
this.addEventListener('touchstart', handle, {passive: true});
|
|
}
|
|
}
|
|
};
|
|
jQuery.event.special.touchmove = {
|
|
setup: function (_, ns, handle) {
|
|
if (ns.includes('noPreventDefault')) {
|
|
this.addEventListener('touchmove', handle, {passive: false});
|
|
} else {
|
|
this.addEventListener('touchmove', handle, {passive: true});
|
|
}
|
|
}
|
|
};
|
|
|
|
const Toast = {
|
|
info: function (msg) {
|
|
Toastify({
|
|
text: msg,
|
|
duration: 3000,
|
|
gravity: 'top', // `top` or `bottom`
|
|
position: 'right', // `left`, `center` or `right`
|
|
backgroundColor: '#4F85FF'
|
|
}).showToast();
|
|
},
|
|
notify: function (msg) {
|
|
Toastify({
|
|
text: msg,
|
|
duration: 3000,
|
|
gravity: 'top', // `top` or `bottom`
|
|
position: 'right', // `left`, `center` or `right`
|
|
backgroundColor: '#2FC259'
|
|
}).showToast();
|
|
},
|
|
error: function (msg) {
|
|
Toastify({
|
|
text: msg,
|
|
duration: 3000,
|
|
gravity: 'top', // `top` or `bottom`
|
|
position: 'right', // `left`, `center` or `right`
|
|
backgroundColor: '#FF310A'
|
|
}).showToast();
|
|
}
|
|
};
|