Skip to content

Commit

Permalink
cleanup example
Browse files Browse the repository at this point in the history
  • Loading branch information
LePips committed Dec 15, 2022
1 parent 0133222 commit c70c9e3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
10 changes: 2 additions & 8 deletions Example/VLCUIExample/Shared/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,8 @@ struct ContentView: View {
ZStack(alignment: .bottom) {
VLCVideoPlayer(configuration: viewModel.configuration)
.proxy(viewModel.proxy)
.onTicksUpdated { ticks, playbackInformation in
viewModel.ticks = ticks
viewModel.totalTicks = playbackInformation.length
viewModel.position = playbackInformation.position
}
.onStateUpdated { state, _ in
viewModel.playerState = state
}
.onStateUpdated(viewModel.onStateUpdated)
.onTicksUpdated(viewModel.onTicksUpdated)

OverlayView(viewModel: viewModel)
.padding()
Expand Down
10 changes: 10 additions & 0 deletions Example/VLCUIExample/Shared/ContentViewModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,14 @@ class ContentViewModel: ObservableObject {
func setCustomPosition(_ newPosition: Float) {
position = newPosition
}

func onStateUpdated(_ newState: VLCVideoPlayer.State, _ playbackInformation: VLCVideoPlayer.PlaybackInformation) {
playerState = newState
}

func onTicksUpdated(_ newTicks: Int, _ playbackInformation: VLCVideoPlayer.PlaybackInformation) {
position = playbackInformation.position
ticks = newTicks
totalTicks = playbackInformation.length
}
}
2 changes: 1 addition & 1 deletion Example/VLCUIExample/Shared/IntExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ extension Int {
formatter.unitsStyle = .positional
formatter.zeroFormattingBehavior = .pad

return formatter.string(from: TimeInterval(Int(self))) ?? "--:--"
return formatter.string(from: TimeInterval(self)) ?? "--:--"
}
}

0 comments on commit c70c9e3

Please # to comment.