mirror of
https://github.com/pierre42100/ComunicWeb
synced 2025-06-19 04:15:17 +00:00
Start to request screen sharing
This commit is contained in:
@ -791,4 +791,31 @@ function IsFullScreen(){
|
||||
*/
|
||||
function checkEmojiCode(s) {
|
||||
return s.match(/^:[a-zA-Z0-9]+:$/) != null
|
||||
}
|
||||
|
||||
/**
|
||||
* Request user screen as stream
|
||||
*
|
||||
* @return {Promise<MediaStream>}
|
||||
*/
|
||||
function requestUserScreen() {
|
||||
return new Promise((onSuccess, onFailure) => {
|
||||
getScreenId(function (error, sourceId, screen_constraints) {
|
||||
|
||||
if(error != null)
|
||||
return onFailure(error)
|
||||
|
||||
// error == null || 'permission-denied' || 'not-installed' || 'installed-disabled' || 'not-chrome'
|
||||
// sourceId == null || 'string' || 'firefox'
|
||||
|
||||
if(navigator.getDisplayMedia) {
|
||||
navigator.getDisplayMedia(screen_constraints).then(onSuccess, onFailure);
|
||||
}
|
||||
else {
|
||||
navigator.mediaDevices.getUserMedia(screen_constraints).then(onSuccess).catch(onFailure);
|
||||
}
|
||||
|
||||
});
|
||||
})
|
||||
|
||||
}
|
@ -254,6 +254,9 @@ class CallWindow extends CustomEvents {
|
||||
// Parse list of menu entries
|
||||
for(const entry of menuEntries) {
|
||||
|
||||
if(entry.needVideo && !this.allowVideo)
|
||||
continue
|
||||
|
||||
const a = createElem2({
|
||||
appendTo: menuEntriesTarget,
|
||||
type: "li",
|
||||
@ -666,14 +669,33 @@ class CallWindow extends CustomEvents {
|
||||
* Start to send this client audio & video
|
||||
*
|
||||
* @param {boolean} includeVideo
|
||||
* @param {boolean} shareScreen
|
||||
*/
|
||||
async startStreaming(includeVideo) {
|
||||
async startStreaming(includeVideo, shareScreen = false) {
|
||||
|
||||
// First, query user media
|
||||
const stream = await navigator.mediaDevices.getUserMedia({
|
||||
video: this.conv.can_have_video_call && includeVideo,
|
||||
audio: true
|
||||
})
|
||||
let videoConstraints = this.conv.can_have_video_call && includeVideo;
|
||||
|
||||
let stream;
|
||||
|
||||
// Get user screen
|
||||
if(includeVideo && shareScreen) {
|
||||
stream = await requestUserScreen(true)
|
||||
|
||||
const second_stream = await navigator.mediaDevices.getUserMedia({
|
||||
audio: true
|
||||
})
|
||||
|
||||
stream.addTrack(second_stream.getAudioTracks()[0])
|
||||
}
|
||||
|
||||
// Use regular webcam
|
||||
else {
|
||||
// First, query user media
|
||||
stream = await navigator.mediaDevices.getUserMedia({
|
||||
video: videoConstraints,
|
||||
audio: true,
|
||||
})
|
||||
}
|
||||
this.mainStream = stream;
|
||||
|
||||
if(includeVideo)
|
||||
|
Reference in New Issue
Block a user