Browse Source

Merge pull request #1321 from nextcloud/fullscreen-share-firefox

Add support for sharing fullscreen on Firefox.
pull/1324/head
Joas Schilling 7 years ago
committed by GitHub
parent
commit
1113220307
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 69
      js/app.js
  2. 17
      js/simplewebrtc.js
  3. 8
      templates/index-public.php
  4. 8
      templates/index.php

69
js/app.js

@ -256,12 +256,64 @@
return;
}
var splitShare = false;
if (window.navigator.userAgent.match('Firefox')) {
var ffver = parseInt(window.navigator.userAgent.match(/Firefox\/(.*)/)[1], 10);
splitShare = (ffver >= 52);
}
// The parent CSS of the menu list items is using "display:block !important",
// so we need to also hide with "!important".
if (webrtc.getLocalScreen()) {
$('#show-window-entry').attr('style','display:none !important');
$('#stop-screen-entry').show();
$('#screensharing-menu').toggleClass('open');
} else {
if (splitShare) {
$('#show-window-entry').show();
$('#stop-screen-entry').attr('style','display:none !important');
$('#screensharing-menu').toggleClass('open');
return;
}
this.startShareScreen();
}
}.bind(this));
$("#show-screen-button").on('click', function() {
var webrtc = OCA.SpreedMe.webrtc;
if (webrtc.getLocalScreen()) {
var currentUser = OCA.SpreedMe.webrtc.connection.getSessionid();
OCA.SpreedMe.sharedScreens.switchScreenToId(currentUser);
} else {
this.startShareScreen('screen');
}
$('#screensharing-menu').toggleClass('open', false);
}.bind(this));
$("#show-window-button").on('click', function() {
var webrtc = OCA.SpreedMe.webrtc;
if (webrtc.getLocalScreen()) {
var currentUser = OCA.SpreedMe.webrtc.connection.getSessionid();
OCA.SpreedMe.sharedScreens.switchScreenToId(currentUser);
} else {
var screensharingButton = $(this);
this.startShareScreen('window');
}
$('#screensharing-menu').toggleClass('open', false);
}.bind(this));
$("#stop-screen-button").on('click', function() {
OCA.SpreedMe.webrtc.stopScreenShare();
});
},
startShareScreen: function(mode) {
var webrtc = OCA.SpreedMe.webrtc;
var screensharingButton = $('#screensharing-button');
screensharingButton.prop('disabled', true);
webrtc.shareScreen(function(err) {
webrtc.shareScreen(mode, function(err) {
screensharingButton.prop('disabled', false);
if (!err) {
$('#screensharing-button').attr('data-original-title', t('spreed', 'Screensharing options'))
@ -302,19 +354,6 @@
break;
}
});
}
});
$("#show-screen-button").on('click', function() {
var currentUser = OCA.SpreedMe.webrtc.connection.getSessionid();
OCA.SpreedMe.sharedScreens.switchScreenToId(currentUser);
$('#screensharing-menu').toggleClass('open', false);
});
$("#stop-screen-button").on('click', function() {
OCA.SpreedMe.webrtc.stopScreenShare();
});
},
_onKeyUp: function(event) {

17
js/simplewebrtc.js

@ -3874,8 +3874,8 @@
// cache for constraints and callback
var cache = {};
module.exports = function (constraints, cb) {
var hasConstraints = arguments.length === 2;
module.exports = function (mode, constraints, cb) {
var hasConstraints = arguments.length === 3;
var callback = hasConstraints ? cb : constraints;
var error;
@ -3970,10 +3970,11 @@
} else if (window.navigator.userAgent.match('Firefox')) {
var ffver = parseInt(window.navigator.userAgent.match(/Firefox\/(.*)/)[1], 10);
if (ffver >= 52) {
mode = mode || 'window';
constraints = (hasConstraints && constraints) || {
video: {
mozMediaSource: 'window',
mediaSource: 'window'
mozMediaSource: mode,
mediaSource: mode
}
};
getUserMedia(constraints, function (err, stream) {
@ -7607,9 +7608,9 @@
});
};
LocalMedia.prototype.startScreenShare = function (cb) {
LocalMedia.prototype.startScreenShare = function (mode, cb) {
var self = this;
getScreenMedia(function (err, stream) {
getScreenMedia(mode, function (err, stream) {
if (!err) {
self.localScreens.push(stream);
@ -18295,8 +18296,8 @@
return this.getEl(this.config.remoteVideosEl);
};
SimpleWebRTC.prototype.shareScreen = function (cb) {
this.webrtc.startScreenShare(cb);
SimpleWebRTC.prototype.shareScreen = function (mode, cb) {
this.webrtc.startScreenShare(mode, cb);
};
SimpleWebRTC.prototype.getLocalScreen = function () {

8
templates/index-public.php

@ -78,7 +78,13 @@ script(
<span><?php p($l->t('Show your screen'));?></span>
</button>
</li>
<li>
<li id="show-window-entry">
<button id="show-window-button">
<span class="icon-screen"></span>
<span><?php p($l->t('Show a single window'));?></span>
</button>
</li>
<li id="stop-screen-entry">
<button id="stop-screen-button">
<span class="icon-screen-off"></span>
<span><?php p($l->t('Stop screensharing'));?></span>

8
templates/index.php

@ -85,7 +85,13 @@ script(
<span><?php p($l->t('Show your screen'));?></span>
</button>
</li>
<li>
<li id="show-window-entry">
<button id="show-window-button">
<span class="icon-screen"></span>
<span><?php p($l->t('Show a single window'));?></span>
</button>
</li>
<li id="stop-screen-entry">
<button id="stop-screen-button">
<span class="icon-screen-off"></span>
<span><?php p($l->t('Stop screensharing'));?></span>

Loading…
Cancel
Save