feat(IFrameApi): setAudioOnly command & event.

This commit is contained in:
Hristo Terezov
2024-11-14 16:48:45 -06:00
parent 6af4d182d0
commit 037a7c082c
3 changed files with 30 additions and 0 deletions

View File

@@ -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.
*

View File

@@ -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',

View File

@@ -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);
}
);