Skip to content

Commit 89f2cde

Browse files
authored
Update video-effects-ios.md
Added background replacement in iOS
1 parent 43af97e commit 89f2cde

File tree

1 file changed

+34
-0
lines changed
  • articles/communication-services/quickstarts/voice-video-calling/includes/video-effects

1 file changed

+34
-0
lines changed

articles/communication-services/quickstarts/voice-video-calling/includes/video-effects/video-effects-ios.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,3 +73,37 @@ To disable Background Blur Video Effect:
7373
```swift
7474
localVideoEffectsFeature.disable(effect: backgroundBlurVideoEffect)
7575
```
76+
77+
### Background Replacement
78+
Background Replacement is a Video Effect that allows a person to set their own custom background. In order to use Background Repalcement Effect, you need to obtain a `LocalVideoEffectsFeature` feature from a valid `LocalVideoStream`.
79+
80+
- Create a new Background Replacement Video Effect object:
81+
82+
```swift
83+
@State var backgroundReplacementVideoEffect: BackgroundReplacementEffect?
84+
```
85+
86+
- Set a custom background by passing in the image through a buffer.
87+
88+
```swift
89+
let image = UIImage(named:"image.png")
90+
guard let imageData = image?.jpegData(compressionQuality: 1.0) else {
91+
return
92+
}
93+
backgroundReplacementVideoEffect.buffer = imageData
94+
```
95+
96+
- Check if `BackgroundReplacementEffect` is supported and call `Enable` on the `videoEffectsFeature` object:
97+
98+
```swift
99+
if((localVideoEffectsFeature.isSupported(effect: backgroundReplacementVideoEffect)) != nil)
100+
{
101+
localVideoEffectsFeature.enable(effect: backgroundReplacementVideoEffect)
102+
}
103+
```
104+
105+
To disable Background Replacement Video Effect:
106+
107+
```swift
108+
localVideoEffectsFeature.disable(effect: backgroundReplacementVideoEffect)
109+
```

0 commit comments

Comments
 (0)