feat(virtual-background): Desktop share as virtual background

This commit is contained in:
tudordan7 2021-05-26 19:01:00 +03:00 committed by Jaya Allamsetty
parent 06c527b6fe
commit c0917f87ae
3 changed files with 11 additions and 4 deletions

View File

@ -341,7 +341,8 @@
"slightBlur": "Slight Blur",
"removeBackground": "Remove background",
"addBackground": "Add background",
"none": "None"
"none": "None",
"desktopShareError": "Could not create desktop share"
},
"feedback": {
"average": "Average",

View File

@ -12,6 +12,7 @@ import { createLocalTrack } from '../../base/lib-jitsi-meet/functions';
import { VIDEO_TYPE } from '../../base/media';
import { connect } from '../../base/redux';
import { getLocalVideoTrack } from '../../base/tracks';
import { showErrorNotification } from '../../notifications';
import { toggleBackgroundEffect } from '../actions';
import { VIRTUAL_BACKGROUND_TYPE } from '../constants';
import { resizeImage, toDataURL } from '../functions';
@ -132,7 +133,12 @@ function VirtualBackground({ _jitsiTrack, _selectedThumbnail, _virtualSource, di
const url = await createLocalTrack('desktop', '');
if (!url) {
throw new Error('Could not create desktop local track!');
dispatch(showErrorNotification({
titleKey: 'virtualBackground.desktopShareError'
}));
logger.error('Could not create desktop share as a virtual background!');
return;
}
setOptions({
backgroundType: VIRTUAL_BACKGROUND_TYPE.DESKTOP_SHARE,

View File

@ -19,8 +19,8 @@ MiddlewareRegistry.register(store => next => action => {
const virtualSource = getState()['features/virtual-background'].virtualSource;
const currentLocalTrack = getLocalVideoTrack(getState()['features/base/tracks']);
if (virtualSource?.videoType === VIDEO_TYPE.DESKTOP && currentLocalTrack) {
localTrackStopped(dispatch, virtualSource, currentLocalTrack.jitsiTrack);
if (virtualSource?.videoType === VIDEO_TYPE.DESKTOP) {
localTrackStopped(dispatch, virtualSource, currentLocalTrack?.jitsiTrack);
}
return next(action);