diff --git a/modules/API/API.js b/modules/API/API.js index 3cf6b2b646..cfcbb3debc 100644 --- a/modules/API/API.js +++ b/modules/API/API.js @@ -14,6 +14,7 @@ import { requestEnableVideoModeration } from '../../react/features/av-moderation/actions'; import { isEnabledFromState } from '../../react/features/av-moderation/functions'; +import { setAudioOnly } from '../../react/features/base/audio-only/actions'; import { endConference, sendTones, @@ -565,6 +566,10 @@ function initCommands() { sendAnalytics(createApiEvent('set.video.quality')); APP.store.dispatch(setVideoQuality(frameHeight)); }, + 'set-audio-only': enable => { + sendAnalytics(createApiEvent('set.audio.only')); + APP.store.dispatch(setAudioOnly(enable)); + }, 'start-share-video': url => { sendAnalytics(createApiEvent('share.video.start')); const id = extractYoutubeIdOrURL(url); @@ -2218,6 +2223,19 @@ class API { }); } + /** + * Notify the external application (if API is enabled) when the audio only enabled status changed. + * + * @param {boolean} enabled - Whether the audio only is enabled or not. + * @returns {void} + */ + notifyAudioOnlyChanged(enabled) { + this._sendEvent({ + name: 'audio-only-changed', + enabled + }); + } + /** * Disposes the allocated resources. * diff --git a/modules/API/external/external_api.js b/modules/API/external/external_api.js index 5f1dc8127a..51c91822cc 100644 --- a/modules/API/external/external_api.js +++ b/modules/API/external/external_api.js @@ -59,6 +59,7 @@ const commands = { sendEndpointTextMessage: 'send-endpoint-text-message', sendParticipantToRoom: 'send-participant-to-room', sendTones: 'send-tones', + setAudioOnly: 'set-audio-only', setAssumedBandwidthBps: 'set-assumed-bandwidth-bps', setBlurredBackground: 'set-blurred-background', setFollowMe: 'set-follow-me', @@ -103,6 +104,7 @@ const events = { 'avatar-changed': 'avatarChanged', 'audio-availability-changed': 'audioAvailabilityChanged', 'audio-mute-status-changed': 'audioMuteStatusChanged', + 'audio-only-changed': 'audioOnlyChanged', 'audio-or-video-sharing-toggled': 'audioOrVideoSharingToggled', 'breakout-rooms-updated': 'breakoutRoomsUpdated', 'browser-support': 'browserSupport', diff --git a/react/features/external-api/subscriber.ts b/react/features/external-api/subscriber.ts index 9dc05e5600..b0afb95bd7 100644 --- a/react/features/external-api/subscriber.ts +++ b/react/features/external-api/subscriber.ts @@ -61,3 +61,13 @@ StateListenerRegistry.register( APP.API.notifyOnStageParticipantChanged(participantId); } ); + +/** + * Updates the on audio only value. + */ +StateListenerRegistry.register( + /* selector */ state => state['features/base/audio-only'].enabled, + /* listener */ enabled => { + APP.API.notifyAudioOnlyChanged(enabled); + } +);