2022-02-16 20:23:11 +00:00
|
|
|
import SwiftUI
|
|
|
|
|
|
|
|
struct PlayerGestures: View {
|
|
|
|
@EnvironmentObject<PlayerModel> private var player
|
|
|
|
@EnvironmentObject<PlayerControlsModel> private var model
|
|
|
|
|
|
|
|
var body: some View {
|
|
|
|
HStack(spacing: 0) {
|
|
|
|
gestureRectangle
|
|
|
|
.tapRecognizer(
|
|
|
|
tapSensitivity: 0.2,
|
2022-07-10 17:51:46 +00:00
|
|
|
singleTapAction: { singleTapAction() },
|
2022-02-16 20:23:11 +00:00
|
|
|
doubleTapAction: {
|
2022-08-28 17:18:49 +00:00
|
|
|
player.backend.seek(relative: .secondsInDefaultTimescale(-10), seekType: .userInteracted)
|
2022-09-01 23:05:31 +00:00
|
|
|
},
|
|
|
|
anyTapAction: {
|
|
|
|
model.update()
|
2022-02-16 20:23:11 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
gestureRectangle
|
|
|
|
.tapRecognizer(
|
|
|
|
tapSensitivity: 0.2,
|
2022-07-10 17:51:46 +00:00
|
|
|
singleTapAction: { singleTapAction() },
|
2022-02-16 20:23:11 +00:00
|
|
|
doubleTapAction: {
|
|
|
|
player.backend.togglePlay()
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
gestureRectangle
|
|
|
|
.tapRecognizer(
|
|
|
|
tapSensitivity: 0.2,
|
2022-07-10 17:51:46 +00:00
|
|
|
singleTapAction: { singleTapAction() },
|
2022-02-16 20:23:11 +00:00
|
|
|
doubleTapAction: {
|
2022-08-28 17:18:49 +00:00
|
|
|
player.backend.seek(relative: .secondsInDefaultTimescale(10), seekType: .userInteracted)
|
2022-02-16 20:23:11 +00:00
|
|
|
}
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-10 17:51:46 +00:00
|
|
|
func singleTapAction() {
|
|
|
|
if model.presentingOverlays {
|
|
|
|
withAnimation(PlayerControls.animation) {
|
|
|
|
model.hideOverlays()
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
model.toggle()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-16 20:23:11 +00:00
|
|
|
var gestureRectangle: some View {
|
|
|
|
Color.clear
|
|
|
|
.contentShape(Rectangle())
|
|
|
|
.frame(maxWidth: .infinity, maxHeight: .infinity)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
struct PlayerGestures_Previews: PreviewProvider {
|
|
|
|
static var previews: some View {
|
|
|
|
PlayerGestures()
|
|
|
|
}
|
|
|
|
}
|