Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
kingslay committed May 15, 2022
1 parent 3916ced commit 0b81eaa
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions Sources/KSPlayer/SwiftUI/KSVideoPlayer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,7 @@ class TVSlide: UIControl {
private let processView = UIProgressView()
private var isTouch = false
private lazy var panGestureRecognizer = UIPanGestureRecognizer(target: self, action: #selector(actionPanGesture(sender:)))
private var beganOffset = Float(0.0)
var process: Binding<Float> {
willSet {
if !isTouch, newValue.wrappedValue != processView.progress {
Expand Down Expand Up @@ -643,15 +644,16 @@ class TVSlide: UIControl {
if abs(translation.y) > abs(translation.x) {
return
}
let touchPoint = sender.location(in: self)
let value = Float(touchPoint.x / frame.size.width)

switch sender.state {
case .began, .possible:
isTouch = true
beganOffset = processView.progress * Float(frame.size.width)
case .changed:
let value = (beganOffset + Float(translation.x) / 5) / Float(frame.size.width)
processView.progress = value
case .ended:
process.wrappedValue = value
process.wrappedValue = processView.progress
isTouch = false
case .cancelled:
isTouch = false
Expand Down

0 comments on commit 0b81eaa

Please sign in to comment.