Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add toggle to show and hide video from other participants #937

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions css/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ video {
}

.muteIndicator,
.hideRemoteVideo,
.screensharingIndicator,
.iceFailedIndicator {
position: relative;
Expand Down
83 changes: 77 additions & 6 deletions js/webrtc.js
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,14 @@ var spreedPeerConnectionTable = [];
muteIndicator.className = 'muteIndicator icon-white icon-shadow icon-audio-off audio-on';
muteIndicator.disabled = true;

var hideRemoteVideoButton = document.createElement('button');
hideRemoteVideoButton.className = 'hideRemoteVideo icon-white icon-shadow icon-video';
hideRemoteVideoButton.setAttribute('style', 'display: none;');
hideRemoteVideoButton.setAttribute('data-original-title', t('spreed', 'Disable video'));
hideRemoteVideoButton.onclick = function() {
OCA.SpreedMe.videos._toggleRemoteVideo(id);
};

var screenSharingIndicator = document.createElement('button');
screenSharingIndicator.className = 'screensharingIndicator icon-white icon-shadow icon-screen screen-off';
screenSharingIndicator.setAttribute('data-original-title', t('spreed', 'Show screen'));
Expand All @@ -283,12 +291,18 @@ var spreedPeerConnectionTable = [];
iceFailedIndicator.className = 'iceFailedIndicator icon-white icon-shadow icon-error not-failed';
iceFailedIndicator.disabled = true;

$(hideRemoteVideoButton).tooltip({
placement: 'top',
trigger: 'hover'
});

$(screenSharingIndicator).tooltip({
placement: 'top',
trigger: 'hover'
});

mediaIndicator.appendChild(muteIndicator);
mediaIndicator.appendChild(hideRemoteVideoButton);
mediaIndicator.appendChild(screenSharingIndicator);
mediaIndicator.appendChild(iceFailedIndicator);

Expand All @@ -303,6 +317,58 @@ var spreedPeerConnectionTable = [];
$(container).prependTo($('#videos'));
return container;
},
muteRemoteVideo: function(id) {
if (!(typeof id === 'string' || id instanceof String)) {
return;
}

var $container = $(OCA.SpreedMe.videos.getContainerId(id));

$container.find('.avatar-container').show();
$container.find('video').hide();
$container.find('.hideRemoteVideo').hide();
},
unmuteRemoteVideo: function(id) {
if (!(typeof id === 'string' || id instanceof String)) {
return;
}

var $container = $(OCA.SpreedMe.videos.getContainerId(id));

var $hideRemoteVideoButton = $container.find('.hideRemoteVideo');
$hideRemoteVideoButton.show();

if ($hideRemoteVideoButton.hasClass('icon-video')) {
$container.find('.avatar-container').hide();
$container.find('video').show();
}
},
_toggleRemoteVideo: function(id) {
if (!(typeof id === 'string' || id instanceof String)) {
return;
}

var $container = $(OCA.SpreedMe.videos.getContainerId(id));

var $hideRemoteVideoButton = $container.find('.hideRemoteVideo');
if ($hideRemoteVideoButton.hasClass('icon-video')) {
$container.find('.avatar-container').show();
$container.find('video').hide();
$hideRemoteVideoButton.attr('data-original-title', t('spreed', 'Enable video'))
.removeClass('icon-video')
.addClass('icon-video-off');
} else {
$container.find('.avatar-container').hide();
$container.find('video').show();
$hideRemoteVideoButton.attr('data-original-title', t('spreed', 'Disable video'))
.removeClass('icon-video-off')
.addClass('icon-video');
}

if (latestSpeakerId === id) {
OCA.SpreedMe.speakers.updateVideoContainerDummy(id);
}
},
remove: function(id) {
if (!(typeof id === 'string' || id instanceof String)) {
return;
Expand Down Expand Up @@ -450,6 +516,15 @@ var spreedPeerConnectionTable = [];
.append(newContainer.find('.speakingIndicator').clone())
);

// Cloning does not copy event handlers by default; it could be
// forced with a parameter, but the tooltip would have to be
// explicitly set on the new element anyway. Due to this the
// click handler is explicitly copied too.
$('.videoContainer-dummy').find('.hideRemoteVideo').get(0).onclick = newContainer.find('.hideRemoteVideo').get(0).onclick;
$('.videoContainer-dummy').find('.hideRemoteVideo').tooltip({
placement: 'top',
trigger: 'hover'
});
},
add: function(id, notPromote) {
if (!(typeof id === 'string' || id instanceof String)) {
Expand Down Expand Up @@ -917,10 +992,7 @@ var spreedPeerConnectionTable = [];
var $el = $(el);

if (data.name === 'video') {
var avatarContainer = $el.find('.avatar-container');
avatarContainer.removeClass('hidden');
avatarContainer.show();
$el.find('video').hide();
OCA.SpreedMe.videos.muteRemoteVideo(data.id);
} else {
var muteIndicator = $el.find('.muteIndicator');
muteIndicator.removeClass('audio-on');
Expand All @@ -943,8 +1015,7 @@ var spreedPeerConnectionTable = [];
var $el = $(el);

if (data.name === 'video') {
$el.find('.avatar-container').hide();
$el.find('video').show();
OCA.SpreedMe.videos.unmuteRemoteVideo(data.id);
} else {
var muteIndicator = $el.find('.muteIndicator');
muteIndicator.removeClass('audio-off');
Expand Down