Skip to content

Commit 6278b6c

Browse files
author
xianing
committed
Add missing features in MacOS demo to align latest API
1 parent ff495fd commit 6278b6c

15 files changed

Lines changed: 589 additions & 221 deletions

File tree

iOS/APIExample/Examples/Advanced/AudioMixing/AudioMixing.swift

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,9 @@ class AudioMixingMain: BaseViewController {
192192
}
193193

194194
@IBAction func onStartAudioMixing(_ sender:UIButton){
195+
var url = "http://ok100-book.oss-cn-beijing.aliyuncs.com/m4a/susu.m4a"
195196
if let filepath = Bundle.main.path(forResource: "audiomixing", ofType: "mp3") {
196-
let result = agoraKit.startAudioMixing(filepath, loopback: false, replace: false, cycle: -1)
197+
let result = agoraKit.startAudioMixing(url, loopback: false, replace: false, cycle: -1)
197198
if result != 0 {
198199
self.showAlert(title: "Error", message: "startAudioMixing call failed: \(result), please check your params")
199200
} else {
@@ -370,4 +371,8 @@ extension AudioMixingMain: AgoraRtcEngineDelegate {
370371
func rtcEngine(_ engine: AgoraRtcEngineKit, remoteAudioStats stats: AgoraRtcRemoteAudioStats) {
371372
audioViews[stats.uid]?.statsInfo?.updateAudioStats(stats)
372373
}
374+
375+
func rtcEngine(_ engine: AgoraRtcEngineKit, localAudioMixingStateDidChanged state: AgoraAudioMixingStateCode, errorCode: AgoraAudioMixingErrorCode) {
376+
LogUtils.log(message: " --- \(state.rawValue) \(errorCode.rawValue)", level: .info)
377+
}
373378
}

iOS/APIExample/Examples/Advanced/PrecallTest/Base.lproj/PrecallTest.storyboard

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="16097.2" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
3-
<device id="retina6_1" orientation="portrait" appearance="light"/>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="17156" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES">
3+
<device id="retina3_5" orientation="portrait" appearance="light"/>
44
<dependencies>
55
<deployment identifier="iOS"/>
6-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="16087"/>
6+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="17125"/>
77
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
8+
<capability name="System colors in document resources" minToolsVersion="11.0"/>
89
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
910
</dependencies>
1011
<scenes>
@@ -13,65 +14,65 @@
1314
<objects>
1415
<viewController storyboardIdentifier="EntryViewController" id="O0d-ef-mTa" customClass="PrecallTestEntry" customModule="APIExample" customModuleProvider="target" sceneMemberID="viewController">
1516
<view key="view" contentMode="scaleToFill" id="iRI-aA-06F">
16-
<rect key="frame" x="0.0" y="0.0" width="414" height="896"/>
17+
<rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
1718
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
1819
<subviews>
1920
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Lastmile Network Pretest" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="3PN-IA-Upy">
20-
<rect key="frame" x="20" y="64" width="202" height="20.5"/>
21+
<rect key="frame" x="20" y="20" width="201" height="20.5"/>
2122
<fontDescription key="fontDescription" style="UICTFontTextStyleHeadline"/>
2223
<nil key="textColor"/>
2324
<nil key="highlightedColor"/>
2425
</label>
25-
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="CVA-Q1-OGl">
26-
<rect key="frame" x="20" y="104.5" width="34" height="30"/>
26+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="CVA-Q1-OGl">
27+
<rect key="frame" x="20" y="60.5" width="34" height="30"/>
2728
<state key="normal" title="Start"/>
2829
<connections>
2930
<action selector="doLastmileTestWithSender:" destination="O0d-ef-mTa" eventType="touchUpInside" id="k1D-tr-V3t"/>
3031
</connections>
3132
</button>
3233
<activityIndicatorView opaque="NO" contentMode="scaleToFill" horizontalHuggingPriority="750" verticalHuggingPriority="750" hidesWhenStopped="YES" style="medium" translatesAutoresizingMaskIntoConstraints="NO" id="Odz-6H-f51">
33-
<rect key="frame" x="230" y="64.5" width="20" height="20"/>
34+
<rect key="frame" x="229" y="20.5" width="20" height="20"/>
3435
</activityIndicatorView>
3536
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Echo Pretest" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="e83-fp-COE">
36-
<rect key="frame" x="20" y="194.5" width="102" height="21"/>
37+
<rect key="frame" x="20" y="150.5" width="102" height="21"/>
3738
<fontDescription key="fontDescription" style="UICTFontTextStyleHeadline"/>
3839
<nil key="textColor"/>
3940
<nil key="highlightedColor"/>
4041
</label>
41-
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="eol-rm-UUy">
42-
<rect key="frame" x="20" y="235.5" width="34" height="30"/>
42+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="eol-rm-UUy">
43+
<rect key="frame" x="20" y="191.5" width="34" height="30"/>
4344
<state key="normal" title="Start"/>
4445
<connections>
4546
<action selector="doEchoTestWithSender:" destination="O0d-ef-mTa" eventType="touchUpInside" id="9Lu-JC-BrL"/>
4647
</connections>
4748
</button>
4849
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="LZ3-DO-CNP">
49-
<rect key="frame" x="20" y="154.5" width="0.0" height="0.0"/>
50+
<rect key="frame" x="20" y="110.5" width="0.0" height="0.0"/>
5051
<fontDescription key="fontDescription" type="system" pointSize="14"/>
5152
<nil key="textColor"/>
5253
<nil key="highlightedColor"/>
5354
</label>
5455
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="" textAlignment="natural" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Udp-zb-AZc">
55-
<rect key="frame" x="20" y="174.5" width="0.0" height="0.0"/>
56+
<rect key="frame" x="20" y="130.5" width="0.0" height="0.0"/>
5657
<fontDescription key="fontDescription" type="system" pointSize="14"/>
5758
<nil key="textColor"/>
5859
<nil key="highlightedColor"/>
5960
</label>
6061
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="3R4-HR-irZ">
61-
<rect key="frame" x="0.0" y="44" width="414" height="818"/>
62+
<rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
6263
<subviews>
6364
<view alpha="0.5" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="QIO-fA-jG2">
64-
<rect key="frame" x="0.0" y="0.0" width="414" height="818"/>
65-
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
65+
<rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
66+
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
6667
</view>
6768
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="10" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="caY-D3-ysY">
68-
<rect key="frame" x="186" y="336" width="42" height="43"/>
69+
<rect key="frame" x="139" y="167" width="42" height="43"/>
6970
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
7071
<nil key="textColor"/>
7172
<nil key="highlightedColor"/>
7273
</label>
7374
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Please say something.." lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="tFL-Md-flt">
74-
<rect key="frame" x="120.5" y="399" width="173" height="20.5"/>
75+
<rect key="frame" x="74" y="230" width="172" height="20.5"/>
7576
<fontDescription key="fontDescription" type="system" weight="light" pointSize="17"/>
7677
<nil key="textColor"/>
7778
<nil key="highlightedColor"/>
@@ -90,20 +91,20 @@
9091
</constraints>
9192
</view>
9293
<view hidden="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="faj-S3-G1d">
93-
<rect key="frame" x="0.0" y="44" width="414" height="818"/>
94+
<rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
9495
<subviews>
9596
<view alpha="0.5" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="b5t-l6-bjQ">
96-
<rect key="frame" x="0.0" y="0.0" width="414" height="818"/>
97-
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
97+
<rect key="frame" x="0.0" y="0.0" width="320" height="480"/>
98+
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
9899
</view>
99100
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="10" textAlignment="natural" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="4WV-kQ-0aJ">
100-
<rect key="frame" x="186" y="336" width="42" height="43"/>
101+
<rect key="frame" x="139" y="167" width="42" height="43"/>
101102
<fontDescription key="fontDescription" type="boldSystem" pointSize="36"/>
102103
<nil key="textColor"/>
103104
<nil key="highlightedColor"/>
104105
</label>
105106
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Now you should hear what you said..." lineBreakMode="tailTruncation" numberOfLines="2" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="MdV-HB-V93">
106-
<rect key="frame" x="67.5" y="399" width="279.5" height="20.5"/>
107+
<rect key="frame" x="21" y="230" width="278.5" height="20.5"/>
107108
<fontDescription key="fontDescription" type="system" weight="light" pointSize="17"/>
108109
<nil key="textColor"/>
109110
<nil key="highlightedColor"/>
@@ -122,7 +123,8 @@
122123
</constraints>
123124
</view>
124125
</subviews>
125-
<color key="backgroundColor" systemColor="systemBackgroundColor" cocoaTouchSystemColor="whiteColor"/>
126+
<viewLayoutGuide key="safeArea" id="wDs-Gr-g1S"/>
127+
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
126128
<constraints>
127129
<constraint firstItem="Odz-6H-f51" firstAttribute="centerY" secondItem="3PN-IA-Upy" secondAttribute="centerY" id="0gm-rm-4Wk"/>
128130
<constraint firstItem="3R4-HR-irZ" firstAttribute="top" secondItem="wDs-Gr-g1S" secondAttribute="top" id="5bj-mU-wBU"/>
@@ -147,7 +149,6 @@
147149
<constraint firstItem="3PN-IA-Upy" firstAttribute="top" secondItem="wDs-Gr-g1S" secondAttribute="top" constant="20" id="vrN-m6-unb"/>
148150
<constraint firstItem="LZ3-DO-CNP" firstAttribute="top" secondItem="CVA-Q1-OGl" secondAttribute="bottom" constant="20" id="zIU-Si-jbb"/>
149151
</constraints>
150-
<viewLayoutGuide key="safeArea" id="wDs-Gr-g1S"/>
151152
</view>
152153
<connections>
153154
<outlet property="echoTestCountDownLabel" destination="caY-D3-ysY" id="FrL-cP-Dki"/>
@@ -165,4 +166,9 @@
165166
<point key="canvasLocation" x="2244.927536231884" y="930.80357142857133"/>
166167
</scene>
167168
</scenes>
169+
<resources>
170+
<systemColor name="systemBackgroundColor">
171+
<color white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
172+
</systemColor>
173+
</resources>
168174
</document>

macOS/APIExample/Commons/Configs.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,9 @@ class Configs {
3232
15,
3333
30
3434
]
35+
static var VideoContentHints:[AgoraVideoContentHint] = [
36+
AgoraVideoContentHint.none,
37+
AgoraVideoContentHint.motion,
38+
AgoraVideoContentHint.details
39+
]
3540
}

macOS/APIExample/Examples/Advanced/AudioMixing/AudioMixing.swift

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import AGEVideoLayout
1111

1212
class AudioMixing: BaseViewController {
1313
let EFFECT_ID:Int32 = 1
14+
let EFFECT_ID_2:Int32 = 2
1415
var videos: [VideoView] = []
1516

1617
@IBOutlet weak var container: AGEVideoContainer!
@@ -26,13 +27,16 @@ class AudioMixing: BaseViewController {
2627
@IBOutlet weak var resumeAudioMixingBtn: NSButton!
2728
@IBOutlet weak var stopAudioMixingBtn: NSButton!
2829
@IBOutlet weak var playAudioEffectBtn: NSButton!
30+
@IBOutlet weak var playAudioEffectBtn2: NSButton!
2931
@IBOutlet weak var pauseAudioEffectBtn: NSButton!
3032
@IBOutlet weak var resumeAudioEffectBtn: NSButton!
3133
@IBOutlet weak var stopAudioEffectBtn: NSButton!
34+
@IBOutlet weak var stopAudioEffectBtn2: NSButton!
3235
@IBOutlet weak var mixingVolumeSlider: NSSlider!
3336
@IBOutlet weak var mixingPlaybackVolumeSlider: NSSlider!
3437
@IBOutlet weak var mixingPublishVolumeSlider: NSSlider!
3538
@IBOutlet weak var effectVolumeSlider: NSSlider!
39+
@IBOutlet weak var effectVolumeSlider2: NSSlider!
3640
@IBOutlet weak var audioMixingProgress: NSProgressIndicator!
3741
@IBOutlet weak var audioMixingDuration: NSTextField!
3842

@@ -128,6 +132,8 @@ class AudioMixing: BaseViewController {
128132
mixingPlaybackVolumeSlider.doubleValue = Double(agoraKit.getAudioMixingPlayoutVolume())
129133
mixingPublishVolumeSlider.doubleValue = Double(agoraKit.getAudioMixingPublishVolume())
130134
effectVolumeSlider.doubleValue = Double(agoraKit.getEffectsVolume())
135+
effectVolumeSlider2.doubleValue = Double(agoraKit.getEffectsVolume())
136+
131137

132138
// start joining channel
133139
// 1. Users can only see each other after they join the
@@ -276,13 +282,29 @@ class AudioMixing: BaseViewController {
276282
}
277283
}
278284

285+
@IBAction func onPlayEffect2(_ sender:NSButton){
286+
if let filepath = Bundle.main.path(forResource: "effectA", ofType: "wav") {
287+
let result = agoraKit.playEffect(EFFECT_ID_2, filePath: filepath, loopCount: -1, pitch: 1, pan: 0, gain: 100, publish: true)
288+
if result != 0 {
289+
self.showAlert(title: "Error", message: "playEffect call failed: \(result), please check your params")
290+
}
291+
}
292+
}
293+
279294
@IBAction func onStopEffect(_ sender:NSButton){
280295
let result = agoraKit.stopEffect(EFFECT_ID)
281296
if result != 0 {
282297
self.showAlert(title: "Error", message: "stopEffect call failed: \(result), please check your params")
283298
}
284299
}
285300

301+
@IBAction func onStopEffect2(_ sender:NSButton){
302+
let result = agoraKit.stopEffect(EFFECT_ID_2)
303+
if result != 0 {
304+
self.showAlert(title: "Error", message: "stopEffect call failed: \(result), please check your params")
305+
}
306+
}
307+
286308
@IBAction func onPauseEffect(_ sender:NSButton){
287309
let result = agoraKit.pauseEffect(EFFECT_ID)
288310
if result != 0 {
@@ -303,6 +325,12 @@ class AudioMixing: BaseViewController {
303325
agoraKit.setEffectsVolume(value)
304326
}
305327

328+
@IBAction func onAudioEffectVolumeChanged2(_ sender: NSSlider) {
329+
let value:Double = Double(sender.intValue)
330+
LogUtils.log(message: "onAudioEffectVolumeChanged \(value)", level: .info)
331+
agoraKit.setVolumeOfEffect(EFFECT_ID_2, withVolume: value)
332+
}
333+
306334
func layoutVideos(_ count: Int) {
307335
videos = []
308336
for i in 0...count - 1 {

0 commit comments

Comments
 (0)