Skip to content

Commit c70c9e3

Browse files
committed
cleanup example
1 parent 0133222 commit c70c9e3

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

Example/VLCUIExample/Shared/ContentView.swift

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,8 @@ struct ContentView: View {
1010
ZStack(alignment: .bottom) {
1111
VLCVideoPlayer(configuration: viewModel.configuration)
1212
.proxy(viewModel.proxy)
13-
.onTicksUpdated { ticks, playbackInformation in
14-
viewModel.ticks = ticks
15-
viewModel.totalTicks = playbackInformation.length
16-
viewModel.position = playbackInformation.position
17-
}
18-
.onStateUpdated { state, _ in
19-
viewModel.playerState = state
20-
}
13+
.onStateUpdated(viewModel.onStateUpdated)
14+
.onTicksUpdated(viewModel.onTicksUpdated)
2115

2216
OverlayView(viewModel: viewModel)
2317
.padding()

Example/VLCUIExample/Shared/ContentViewModel.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,14 @@ class ContentViewModel: ObservableObject {
3333
func setCustomPosition(_ newPosition: Float) {
3434
position = newPosition
3535
}
36+
37+
func onStateUpdated(_ newState: VLCVideoPlayer.State, _ playbackInformation: VLCVideoPlayer.PlaybackInformation) {
38+
playerState = newState
39+
}
40+
41+
func onTicksUpdated(_ newTicks: Int, _ playbackInformation: VLCVideoPlayer.PlaybackInformation) {
42+
position = playbackInformation.position
43+
ticks = newTicks
44+
totalTicks = playbackInformation.length
45+
}
3646
}

Example/VLCUIExample/Shared/IntExtensions.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@ extension Int {
99
formatter.unitsStyle = .positional
1010
formatter.zeroFormattingBehavior = .pad
1111

12-
return formatter.string(from: TimeInterval(Int(self))) ?? "--:--"
12+
return formatter.string(from: TimeInterval(self)) ?? "--:--"
1313
}
1414
}

0 commit comments

Comments
 (0)