Jitsi Meet - Secure, Simple and Scalable Video Conferences that you use as a standalone app or embed in your web application.
TypeScript debiandeep-videojitsijitsi-meetscalable-video-conferencessfuvideovideo-communicationvideo-conferencingwebrtc
feat(external-api) add function to change virtual backgrounds
Hannesa4a1619dc2ba
diff --git a/modules/API/API.js b/modules/API/API.jsindex cfcbb3debc..3926474b98 100644--- a/modules/API/API.js+++ b/modules/API/API.js@@ -122,7 +122,8 @@ import { isAudioMuteButtonDisabled } from '../../react/features/toolbox/functionimport { setTileView, toggleTileView } from '../../react/features/video-layout/actions.any';import { muteAllParticipants } from '../../react/features/video-menu/actions';import { setVideoQuality } from '../../react/features/video-quality/actions';-import { toggleBlurredBackgroundEffect } from '../../react/features/virtual-background/actions';+import { toggleBackgroundEffect, toggleBlurredBackgroundEffect } from '../../react/features/virtual-background/actions';+import { VIRTUAL_BACKGROUND_TYPE } from '../../react/features/virtual-background/constants';import { toggleWhiteboard } from '../../react/features/whiteboard/actions.web';import { getJitsiMeetTransport } from '../transport';@@ -871,6 +872,16 @@ function initCommands() {},'toggle-whiteboard': () => {APP.store.dispatch(toggleWhiteboard());+ },+ 'set-virtual-background': (enabled, backgroundImage) => {+ const tracks = APP.store.getState()['features/base/tracks'];+ const jitsiTrack = getLocalVideoTrack(tracks)?.jitsiTrack;++ APP.store.dispatch(toggleBackgroundEffect({+ backgroundEffectEnabled: enabled,+ backgroundType: VIRTUAL_BACKGROUND_TYPE.IMAGE,+ virtualSource: backgroundImage+ }, jitsiTrack));}};transport.on('event', ({ data, name }) => {diff --git a/modules/API/external/external_api.js b/modules/API/external/external_api.jsindex 51c91822cc..eafcc4b79a 100644--- a/modules/API/external/external_api.js+++ b/modules/API/external/external_api.js@@ -70,6 +70,7 @@ const commands = {setSubtitles: 'set-subtitles',setTileView: 'set-tile-view',setVideoQuality: 'set-video-quality',+ setVirtualBackground: 'set-virtual-background',showNotification: 'show-notification',startRecording: 'start-recording',startShareVideo: 'start-share-video',@@ -1500,4 +1501,15 @@ export default class JitsiMeetExternalAPI extends EventEmitter {index }));}}++ /**+ * Enable or disable the virtual background with a custom base64 image.+ *+ * @param {boolean} enabled - The boolean value to enable or disable.+ * @param {string} backgroundImage - The base64 image.+ * @returns {void}+ */+ setVirtualBackground(enabled, backgroundImage) {+ this.executeCommand('setVirtualBackground', enabled, backgroundImage);+ }}