diff --git a/example/src/renderer/examples/advanced/VirtualBackground/VirtualBackground.tsx b/example/src/renderer/examples/advanced/VirtualBackground/VirtualBackground.tsx index fcc8d43a7..de61b0453 100644 --- a/example/src/renderer/examples/advanced/VirtualBackground/VirtualBackground.tsx +++ b/example/src/renderer/examples/advanced/VirtualBackground/VirtualBackground.tsx @@ -51,10 +51,10 @@ export default class VirtualBackground joinChannelSuccess: false, remoteUsers: [], startPreview: false, - encodeAlpha: true, + encodeAlpha: false, video_module_position: VideoModulePosition.PositionPreEncoder, background_source_type: BackgroundSourceType.BackgroundNone, - color: 0xffffff, + color: 0xff0000, source: getResourcePath('agora-logo.png'), blur_degree: BackgroundBlurDegree.BlurDegreeMedium, }; @@ -232,6 +232,18 @@ export default class VirtualBackground items={enumToItems(BackgroundSourceType)} value={background_source_type} onValueChange={(value) => { + if (value !== BackgroundSourceType.BackgroundNone) { + this.engine?.setVideoEncoderConfiguration({ + advanceOptions: { + encodeAlpha: false, + }, + }); + this.setState({ + video_module_position: VideoModulePosition.PositionPreEncoder, + encodeAlpha: false, + }); + } + this.disableVirtualBackground(); this.setState({ background_source_type: value }); }} /> @@ -266,34 +278,38 @@ export default class VirtualBackground }} /> ) : null} - { - this.setState({ - video_module_position: value - ? VideoModulePosition.PositionPostCapturer - : VideoModulePosition.PositionPreEncoder, - }); - }} - /> - { - this.setState({ encodeAlpha: value }); - this.engine?.setVideoEncoderConfiguration({ - advanceOptions: { - encodeAlpha: value, - }, - }); - }} - /> + {background_source_type === BackgroundSourceType.BackgroundNone ? ( + { + this.setState({ + video_module_position: value + ? VideoModulePosition.PositionPostCapturer + : VideoModulePosition.PositionPreEncoder, + }); + }} + /> + ) : null} + {background_source_type === BackgroundSourceType.BackgroundNone ? ( + { + this.setState({ encodeAlpha: value }); + this.engine?.setVideoEncoderConfiguration({ + advanceOptions: { + encodeAlpha: value, + }, + }); + }} + /> + ) : null} ); } diff --git a/ts/Utils.ts b/ts/Utils.ts index e786beab3..200d77219 100644 --- a/ts/Utils.ts +++ b/ts/Utils.ts @@ -1,4 +1,4 @@ -import { AgoraEnvType } from './Types'; +import { AgoraEnvType, VideoFallbackStrategy } from './Types'; /** * @ignore @@ -192,5 +192,5 @@ export const AgoraEnv: AgoraEnvType = { webEnvReady: true, enableWebCodecsDecoder: false, encodeAlpha: false, - videoFallbackStrategy: 0, + videoFallbackStrategy: VideoFallbackStrategy.PerformancePriority, };