Skip to content

Commit 0b74f8f

Browse files
committed
Major clean up and bring back StreamUI SwiftUI wrapper
1 parent 1d60d7b commit 0b74f8f

File tree

17 files changed

+880
-907
lines changed

17 files changed

+880
-907
lines changed

.github/workflows/swift-ci.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
workflow_dispatch:
9+
10+
jobs:
11+
build-and-test:
12+
name: Build & Test on ${{ matrix.os }} with Swift 5.10
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
matrix:
16+
os: [ubuntu-latest, macos-latest]
17+
18+
steps:
19+
- uses: actions/checkout@v4
20+
21+
- name: Set up Swift
22+
uses: swift-actions/setup-swift@65540b95f51493d65f5e59e97dcef9629ddf11bf
23+
with:
24+
swift-version: '5.10'
25+
26+
- name: Build
27+
run: swift build
28+
29+
- name: Run tests
30+
run: swift test

Examples/CLIExample/index.swift

Lines changed: 65 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -114,52 +114,72 @@ import VideoViews
114114
// Or if you don't want the View to see the rendering with controls you can:
115115
//
116116
//
117-
118117
@main
119-
enum CLIExample {
120-
static func main() async throws {
121-
let recorder = createStreamUIRecorder(
122-
fps: 30,
123-
width: 1080,
124-
height: 1920,
125-
displayScale: 2.0,
126-
captureDuration: .seconds(7),
127-
saveVideoFile: true
128-
) {
129-
// BasicCounterView(initialCounter: 0)
130-
// VideoTestView()
131-
ImageTestView()
132-
// SoundTestView()
133-
// SpriteKitTestView()
134-
// SceneKitTestView()
135-
}
136-
137-
let controlledClock = recorder.controlledClock
138-
139-
recorder.startRecording()
140-
141-
// try await Task.sleep(for: .seconds(5))
142-
//// try await controlledClock.sleep(for: 5.0)
143-
// recorder.pauseRecording()
144-
// try await Task.sleep(for: .seconds(10))
145-
//// try await controlledClock.sleep(for: 10.0)
146-
// recorder.resumeRecording()
147-
// recorder.stopRecording()
148-
// try await Task.sleep(for: .seconds(2))
149-
// recorder.resumeRecording()
150-
151-
// Wait for the recording to complete
152-
await recorder.waitForRecordingCompletion()
153-
154-
// while recorder.isRecording {
155-
// print("while recording")
156-
// try await Task.sleep(for: .seconds(5))
157-
// print("waited five secs")
158-
// recorder.isPaused.toggle()
159-
// try await Task.sleep(for: .seconds(2))
160-
// recorder.isPaused.toggle()
161-
// }
118+
struct CLIExample: App {
119+
@Environment(\.displayScale) private var displayScale
162120

163-
// try await Task.sleep(for: .seconds(1.0))
121+
var body: some Scene {
122+
WindowGroup {
123+
StreamUI(
124+
fps: 30,
125+
width: 1080,
126+
height: 1920,
127+
displayScale: displayScale,
128+
// captureDuration: .seconds(5),
129+
saveVideoFile: true
130+
) {
131+
BasicCounterView(initialCounter: 0)
132+
}
133+
}
164134
}
165135
}
136+
137+
// @main
138+
// enum CLIExample {
139+
// static func main() async throws {
140+
// let recorder = createStreamUIRecorder(
141+
// fps: 30,
142+
// width: 1080,
143+
// height: 1920,
144+
// displayScale: 2.0,
145+
// captureDuration: .seconds(7),
146+
// saveVideoFile: true
147+
// ) {
148+
// BasicCounterView(initialCounter: 0)
149+
//// VideoTestView()
150+
//// ImageTestView()
151+
//// SoundTestView()
152+
//// SpriteKitTestView()
153+
//// SceneKitTestView()
154+
// }
155+
//
156+
// let controlledClock = recorder.controlledClock
157+
//
158+
// recorder.startRecording()
159+
//
160+
//// try await Task.sleep(for: .seconds(5))
161+
//// recorder.stopRecording()
162+
// // try await controlledClock.sleep(for: 5.0)
163+
//// recorder.pauseRecording()
164+
//// try await Task.sleep(for: .seconds(10))
165+
// //// try await controlledClock.sleep(for: 10.0)
166+
//// recorder.resumeRecording()
167+
//// recorder.stopRecording()
168+
//// try await Task.sleep(for: .seconds(2))
169+
//// recorder.resumeRecording()
170+
//
171+
// // Wait for the recording to complete
172+
// await recorder.waitForRecordingCompletion()
173+
//
174+
//// while recorder.isRecording {
175+
//// print("while recording")
176+
//// try await Task.sleep(for: .seconds(5))
177+
//// print("waited five secs")
178+
//// recorder.isPaused.toggle()
179+
//// try await Task.sleep(for: .seconds(2))
180+
//// recorder.isPaused.toggle()
181+
//// }
182+
//
183+
//// try await Task.sleep(for: .seconds(1.0))
184+
// }
185+
// }

Examples/VideoViews/BasicCounterView.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,10 @@ public struct BasicCounterView: View {
5454

5555
Task {
5656
print("going to load")
57-
try await recorder?.loadAudio(from: audioUrl)
57+
// try await recorder?.loadAudio(from: audioUrl)
5858
print("loaded audio")
5959

60-
recorder?.playAudio(from: audioUrl)
60+
// recorder?.playAudio(from: audioUrl)
6161
}
6262
// recorder.l
6363
// playAudio()
@@ -83,10 +83,8 @@ public struct BasicCounterView: View {
8383
private func startTimer() {
8484
Task {
8585
while true {
86-
print("TIMER LOOP")
8786
// print("RECORDER COUNT", recorder?.frameCount)
8887
try await recorder?.controlledClock.clock.sleep(for: .seconds(1.0))
89-
print("TIMER LOOP AFETER")
9088
// try await recorder?.clock.sleep(for: .seconds(1.0 / Double(30)))
9189
counter += 1
9290
}

Package.resolved

Lines changed: 46 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Package.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ let package = Package(
2222
.package(url: "https://github.com/stencilproject/Stencil.git", from: "0.15.1"),
2323
.package(url: "https://github.com/pointfreeco/swift-clocks.git", from: "1.0.2"),
2424
.package(url: "https://github.com/kean/Nuke.git", from: "12.7.3"),
25+
.package(url: "https://github.com/vapor/console-kit.git", from: "4.14.3"),
2526

2627
],
2728
targets: [
@@ -32,6 +33,7 @@ let package = Package(
3233
.product(name: "Logging", package: "swift-log"),
3334
.product(name: "Clocks", package: "swift-clocks"),
3435
.product(name: "Nuke", package: "Nuke"),
36+
.product(name: "ConsoleKit", package: "console-kit"),
3537
],
3638
path: "Sources/StreamUI",
3739
resources: [

0 commit comments

Comments
 (0)