This is an automated email from the ASF dual-hosted git repository.

solomax pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openmeetings.git


The following commit(s) were added to refs/heads/master by this push:
     new 36e030fd3 [OPENMEETINGS-2846] code simplified
36e030fd3 is described below

commit 36e030fd333c91cb770b01d4ff518e9925921b34
Author: Maxim Solodovnik <[email protected]>
AuthorDate: Fri Nov 6 14:09:17 2026 +0700

    [OPENMEETINGS-2846] code simplified
---
 openmeetings-web/src/main/front/src/room/video.js | 68 ++++++++++-------------
 1 file changed, 29 insertions(+), 39 deletions(-)

diff --git a/openmeetings-web/src/main/front/src/room/video.js 
b/openmeetings-web/src/main/front/src/room/video.js
index 3cf227ca7..7d4ebdf4f 100644
--- a/openmeetings-web/src/main/front/src/room/video.js
+++ b/openmeetings-web/src/main/front/src/room/video.js
@@ -42,49 +42,39 @@ module.exports = class Video {
                        }
                }
                function _getScreenStream(msg, state, callback) {
-                       const b = VideoUtil.browser;
-                       let promise, cnts;
-                       if (VideoUtil.isEdge() && b.major > 16) {
-                               cnts = {
-                                       video: true
-                               };
-                               promise = navigator.getDisplayMedia(cnts);
-                       } else if (VideoUtil.sharingSupported()) {
-                               cnts = {
-                                       video: true
-                               };
-                               if (VideoUtil.isSafari()) {
-                                       promise = new Promise(resolve => {
-                                               
VideoUtil.askPermission(resolve);
-                                       }).then(() => {console.log("Promise 
resolved ready to getDisplayMedia!"); return 
navigator.mediaDevices.getDisplayMedia(cnts)
-                                       //FIXME TODO });
-                                       }).catch(err => {
-                                               console.log("Error in the 
middle!");
-                               OmUtil.error(err);
-                                       })
-                               } else {
-                                       promise = 
navigator.mediaDevices.getDisplayMedia(cnts);
-                               }
-                       } else {
-                               promise = new Promise(() => {
-                                       Sharer.close();
-                                       throw 'Screen-sharing is not supported 
in ' + b.name + '[' + b.major + ']';
-                               });
-                       }
-                       promise.then(stream => {
-                               console.log("Got stream!!");
-                               if (state.disposed) {
-                                       throw new Error("MediaStream already 
disposed");
-                               }
-                               __createVideo(state);
-                               state.stream = stream;
-                               callback(msg, state, cnts);
-                       }).catch(err => {
+                       const handleError = err => {
                                VideoMgrUtil.sendMessage({id: 'errorSharing'});
                                Sharer.setShareState(Sharer.SHARE_STOPPED);
                                Sharer.setRecState(Sharer.SHARE_STOPPED);
                                OmUtil.error(err);
-                       });
+                       };
+                       if (!VideoUtil.sharingSupported()) {
+                               const b = VideoUtil.browser;
+                               Sharer.close();
+                               handleError(new Error('Screen-sharing is not 
supported in ' + b.name + '[' + b.major + ']'));
+                               return;
+                       }
+                       const startCapture = () => {
+                               const constraints = { video: true };
+                               
navigator.mediaDevices.getDisplayMedia(constraints)
+                                       .then(stream => {
+                                               console.log(`Got stream!! 
active ? ${stream.active}`);
+                                               if (state.disposed) {
+                                                       throw new 
Error("MediaStream already disposed");
+                                               }
+                                               __createVideo(state);
+                                               state.stream = stream;
+                                               callback(msg, state, 
constraints);
+                                       }).catch(err => {
+                                               handleError(err);
+                                       });
+                       };
+
+                       if (VideoUtil.isSafari()) {
+                               VideoUtil.askPermission(startCapture);
+                       } else {
+                               startCapture();
+                       }
                }
                function _getVideoStream(msg, state, callback) {
                        VideoSettings.constraints(sd, function(cnts) {

Reply via email to