Skip to content

Commit 3ef3de4

Browse files
author
xianing
committed
Adjust Virtual Background UI
1 parent 7cc49e6 commit 3ef3de4

4 files changed

Lines changed: 25 additions & 5 deletions

File tree

macOS/APIExample.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@
8888
57AF397B259B31AA00601E02 /* RawAudioData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 57AF397A259B31AA00601E02 /* RawAudioData.swift */; };
8989
57AF3981259B329B00601E02 /* RawAudioData.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 57AF3980259B329B00601E02 /* RawAudioData.storyboard */; };
9090
596A9F79AF0CD8DC1CA93253 /* Pods_APIExample.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6F65EF2B97B89DE4581B426B /* Pods_APIExample.framework */; };
91+
8B733B8C267B1C0B00CC3DE3 /* bg.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 8B733B8B267B1C0B00CC3DE3 /* bg.jpg */; };
9192
EBDD0209B272C276B21B6270 /* Pods_APIExample_APIExampleUITests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = FC2BAB0AC82140B7CEEA31DA /* Pods_APIExample_APIExampleUITests.framework */; };
9293
/* End PBXBuildFile section */
9394

@@ -229,6 +230,7 @@
229230
57AF3980259B329B00601E02 /* RawAudioData.storyboard */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; path = RawAudioData.storyboard; sourceTree = "<group>"; };
230231
6F65EF2B97B89DE4581B426B /* Pods_APIExample.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_APIExample.framework; sourceTree = BUILT_PRODUCTS_DIR; };
231232
84C863718A380DFD36ABF19F /* Pods-APIExample.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-APIExample.debug.xcconfig"; path = "Target Support Files/Pods-APIExample/Pods-APIExample.debug.xcconfig"; sourceTree = "<group>"; };
233+
8B733B8B267B1C0B00CC3DE3 /* bg.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = bg.jpg; sourceTree = "<group>"; };
232234
B53F41CB5AC550EA43C47363 /* Pods-APIExampleTests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-APIExampleTests.debug.xcconfig"; path = "Target Support Files/Pods-APIExampleTests/Pods-APIExampleTests.debug.xcconfig"; sourceTree = "<group>"; };
233235
B91A67063F1DBE9F621B114C /* Pods-APIExample-APIExampleUITests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-APIExample-APIExampleUITests.release.xcconfig"; path = "Target Support Files/Pods-APIExample-APIExampleUITests/Pods-APIExample-APIExampleUITests.release.xcconfig"; sourceTree = "<group>"; };
234236
DC004435A834772C836F5662 /* Pods-APIExample-APIExampleUITests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-APIExample-APIExampleUITests.debug.xcconfig"; path = "Target Support Files/Pods-APIExample-APIExampleUITests/Pods-APIExample-APIExampleUITests.debug.xcconfig"; sourceTree = "<group>"; };
@@ -453,6 +455,7 @@
453455
034C629D25297ABB00296ECF /* Resources */ = {
454456
isa = PBXGroup;
455457
children = (
458+
8B733B8B267B1C0B00CC3DE3 /* bg.jpg */,
456459
57A635F32593544600EDC2F7 /* effectA.wav */,
457460
034C629E25297ABB00296ECF /* audioeffect.mp3 */,
458461
034C629F25297ABB00296ECF /* audiomixing.mp3 */,
@@ -789,6 +792,7 @@
789792
03896D3424F8A011008593CD /* Assets.xcassets in Resources */,
790793
03896D3724F8A011008593CD /* Main.storyboard in Resources */,
791794
033A9FE0252EB58600BC26E1 /* CustomVideoSourceMediaIO.storyboard in Resources */,
795+
8B733B8C267B1C0B00CC3DE3 /* bg.jpg in Resources */,
792796
033A9FB3252EAEB500BC26E1 /* JoinChannelVideo.storyboard in Resources */,
793797
033A9FC7252EB03700BC26E1 /* CustomVideoRender.storyboard in Resources */,
794798
036D3AA024FA40EB00B1D8DC /* VideoView.xib in Resources */,

macOS/APIExample/Examples/Basic/JoinChannelVideo/Base.lproj/JoinChannelVideo.storyboard

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="17701" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="18122" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES">
33
<dependencies>
44
<deployment identifier="macosx"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="17701"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="18122"/>
66
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
77
</dependencies>
88
<scenes>
@@ -60,6 +60,13 @@
6060
<rect key="frame" x="27" y="165" width="260" height="50"/>
6161
<autoresizingMask key="autoresizingMask" widthSizable="YES" flexibleMinY="YES"/>
6262
</view>
63+
<switch horizontalHuggingPriority="750" verticalHuggingPriority="750" fixedFrame="YES" baseWritingDirection="leftToRight" alignment="left" translatesAutoresizingMaskIntoConstraints="NO" id="yxJ-ha-sZW">
64+
<rect key="frame" x="247" y="133" width="42" height="25"/>
65+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
66+
<connections>
67+
<action selector="onSwitchVirtualBackground:" target="YjT-yy-DnJ" id="mb2-DP-kro"/>
68+
</connections>
69+
</switch>
6370
</subviews>
6471
</view>
6572
</subviews>
@@ -137,6 +144,7 @@
137144
<outlet property="selectMicsPicker" destination="hcG-z6-b03" id="9Iw-WB-9xr"/>
138145
<outlet property="selectResolutionPicker" destination="Umi-Rd-77k" id="rPy-Nf-42S"/>
139146
<outlet property="selectRolePicker" destination="zNc-vL-43g" id="qWk-5W-NrG"/>
147+
<outlet property="virtualBackgroundSwitch" destination="yxJ-ha-sZW" id="tz5-dX-OSU"/>
140148
</connections>
141149
</viewController>
142150
<customObject id="sAD-hK-POR" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>

macOS/APIExample/Examples/Basic/JoinChannelVideo/JoinChannelVideo.swift

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ class JoinChannelVideoMain: BaseViewController {
1616
var videos: [VideoView] = []
1717
@IBOutlet weak var Container: AGEVideoContainer!
1818

19+
var isVirtualBackgroundEnabled: Bool = false
20+
@IBOutlet weak var virtualBackgroundSwitch: NSSwitch!
21+
1922
/**
2023
--- Cameras Picker ---
2124
*/
@@ -232,7 +235,7 @@ class JoinChannelVideoMain: BaseViewController {
232235
}
233236
}
234237
func initSelectBackgroundPicker() {
235-
selectBackgroundPicker.label.stringValue = "Camera Background Setting".localized
238+
selectBackgroundPicker.label.stringValue = "Virtual Background".localized
236239
selectBackgroundPicker.picker.addItems(withTitles: backgroundTypes.map { $0.description() })
237240
selectBackgroundPicker.onSelectChanged {
238241
guard self.selectedBackgroundType != nil else { return }
@@ -308,7 +311,7 @@ class JoinChannelVideoMain: BaseViewController {
308311
default:
309312
break
310313
}
311-
agoraKit.enableVirtualBackground(true, backData: backgroundSource)
314+
agoraKit.enableVirtualBackground(isVirtualBackgroundEnabled, backData: backgroundSource)
312315
}
313316

314317
func layoutVideos(_ count: Int) {
@@ -330,6 +333,11 @@ class JoinChannelVideoMain: BaseViewController {
330333
Container.layoutStream(views: videos)
331334
}
332335

336+
@IBAction func onSwitchVirtualBackground(_ sender: NSSwitch) {
337+
isVirtualBackgroundEnabled = (sender.state.rawValue != 0)
338+
setBackground()
339+
}
340+
333341
@IBAction func onVideoCallButtonPressed(_ sender: NSButton) {
334342
if !isJoined {
335343
// check configuration

macOS/APIExample/Localizable.strings

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,4 +160,4 @@
160160
"None" = "无背景";
161161
"Colored Background" = "纯色背景";
162162
"Image Background" = "图片背景";
163-
"Camera Background Setting" = "主播背景设置";
163+
"Virtual Background" = "虚拟背景";

0 commit comments

Comments
 (0)