-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathStepService.swift
More file actions
33 lines (26 loc) · 838 Bytes
/
StepService.swift
File metadata and controls
33 lines (26 loc) · 838 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//
// StepService.swift
// Youtube-Example
//
// Created by shayanbo on 2023/7/9.
//
import Foundation
import VideoPlayerContainer
import Combine
class StepService : Service {
private var cancellables = [AnyCancellable]()
required init(_ context: Context) {
super.init(context)
context.gesture.observe(.doubleTap(.all)) { [weak context] event in
guard let player = context?[RenderService.self].player else { return }
switch event.gesture {
case .doubleTap(.left):
player.currentItem?.step(byCount: -30 * 5)
case .doubleTap(.right):
player.currentItem?.step(byCount: 30 * 5)
default: break
}
player.play()
}.store(in: &cancellables)
}
}