Skip to content

Commit 89b3a87

Browse files
authored
Handle typed agent states (#27)
Needs SDK update first (pin).
1 parent 81a66e9 commit 89b3a87

File tree

3 files changed

+8
-11
lines changed

3 files changed

+8
-11
lines changed

Package.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ let package = Package(
99
.iOS(.v14),
1010
.macOS(.v11),
1111
.macCatalyst(.v14),
12-
.visionOS(.v1),
1312
.tvOS(.v17),
1413
],
1514
products: [
@@ -19,7 +18,7 @@ let package = Package(
1918
),
2019
],
2120
dependencies: [
22-
.package(url: "https://github.com/livekit/client-sdk-swift.git", from: "2.6.0"),
21+
.package(url: "https://github.com/livekit/client-sdk-swift.git", from: "2.7.0"),
2322
.package(url: "https://github.com/apple/swift-docc-plugin.git", from: "1.4.3"),
2423
],
2524
targets: [

[email protected]

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ let package = Package(
99
.iOS(.v14),
1010
.macOS(.v11),
1111
.macCatalyst(.v14),
12-
.visionOS(.v1),
12+
.visionOS(.v2),
1313
.tvOS(.v17),
1414
],
1515
products: [
@@ -19,7 +19,7 @@ let package = Package(
1919
),
2020
],
2121
dependencies: [
22-
.package(url: "https://github.com/livekit/client-sdk-swift.git", from: "2.6.0"),
22+
.package(url: "https://github.com/livekit/client-sdk-swift.git", from: "2.7.0"),
2323
.package(url: "https://github.com/apple/swift-docc-plugin.git", from: "1.4.3"),
2424
],
2525
targets: [

Sources/LiveKitComponents/UI/Visualizer/BarAudioVisualizer.swift

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public struct BarAudioVisualizer: View {
8484
@State private var animationTask: Task<Void, Never>?
8585

8686
public init(audioTrack: AudioTrack?,
87-
agentState: AgentState = .unknown,
87+
agentState: AgentState = .speaking,
8888
barColor: Color = .primary,
8989
barCount: Int = 5,
9090
barCornerRadius: CGFloat = 100,
@@ -180,21 +180,19 @@ extension BarAudioVisualizer {
180180

181181
func duration(agentState: AgentState) -> TimeInterval {
182182
switch agentState {
183-
case .connecting, .initializing: 2 / Double(barCount)
183+
case .idle, .initializing: 2 / Double(barCount)
184184
case .listening: 0.5
185185
case .thinking: 0.15
186186
case .speaking: veryLongDuration
187-
default: veryLongDuration
188187
}
189188
}
190189

191190
func highlightingSequence(agentState: AgentState) -> [HighlightedBars] {
192191
switch agentState {
193-
case .connecting, .initializing: (0 ..< barCount).map { HighlightedBars([$0, barCount - 1 - $0]) }
194-
case .thinking: Array((0 ..< barCount) + (0 ..< barCount).reversed()).map { HighlightedBars([$0]) }
192+
case .idle, .initializing: (0 ..< barCount).map { HighlightedBars([$0, barCount - 1 - $0]) }
195193
case .listening: barCount % 2 == 0 ? [[(barCount / 2) - 1, barCount / 2], []] : [[barCount / 2], []]
196-
case .speaking, .unknown: [HighlightedBars(0 ..< barCount)]
197-
case .disconnected: [[]]
194+
case .thinking: Array((0 ..< barCount) + (0 ..< barCount).reversed()).map { HighlightedBars([$0]) }
195+
case .speaking: [HighlightedBars(0 ..< barCount)]
198196
}
199197
}
200198
}

0 commit comments

Comments
 (0)