mirror of
https://github.com/cranci1/Sora.git
synced 2026-03-11 17:45:37 +00:00
mb done
This commit is contained in:
parent
85355336c9
commit
441cb22abc
2 changed files with 26 additions and 0 deletions
|
|
@ -44,6 +44,10 @@ class CustomMediaPlayerViewController: UIViewController {
|
|||
var brightnessValue: Double = Double(UIScreen.main.brightness)
|
||||
var brightnessSliderHostingController: UIHostingController<VerticalBrightnessSlider<Double>>?
|
||||
|
||||
private var isHoldPauseEnabled: Bool {
|
||||
UserDefaults.standard.bool(forKey: "holdForPauseEnabled")
|
||||
}
|
||||
|
||||
var showWatchNextButton = true
|
||||
var watchNextButtonTimer: Timer?
|
||||
var isWatchNextRepositioned: Bool = false
|
||||
|
|
@ -178,6 +182,10 @@ class CustomMediaPlayerViewController: UIViewController {
|
|||
self?.checkForHLSStream()
|
||||
}
|
||||
|
||||
if isHoldPauseEnabled {
|
||||
holdForPause()
|
||||
}
|
||||
|
||||
player.play()
|
||||
|
||||
if let url = subtitlesURL, !url.isEmpty {
|
||||
|
|
@ -409,6 +417,12 @@ class CustomMediaPlayerViewController: UIViewController {
|
|||
])
|
||||
}
|
||||
|
||||
func holdForPause() {
|
||||
let holdForPauseGesture = UILongPressGestureRecognizer(target: self, action: #selector(handleHoldForPause(_:)))
|
||||
holdForPauseGesture.minimumPressDuration = 2.0
|
||||
holdForPauseGesture.numberOfTouchesRequired = 2
|
||||
view.addGestureRecognizer(holdForPauseGesture)
|
||||
}
|
||||
|
||||
func brightnessControl() {
|
||||
let brightnessSlider = VerticalBrightnessSlider(
|
||||
|
|
@ -1024,6 +1038,14 @@ class CustomMediaPlayerViewController: UIViewController {
|
|||
player.seek(to: CMTime(seconds: currentTimeVal, preferredTimescale: 600))
|
||||
}
|
||||
|
||||
@objc private func handleHoldForPause(_ gesture: UILongPressGestureRecognizer) {
|
||||
guard isHoldPauseEnabled else { return }
|
||||
|
||||
if gesture.state == .began {
|
||||
togglePlayPause()
|
||||
}
|
||||
}
|
||||
|
||||
func speedChangerMenu() -> UIMenu {
|
||||
let speeds: [Double] = [0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 1.75, 2.0]
|
||||
let playbackSpeedActions = speeds.map { speed in
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ struct SettingsViewPlayer: View {
|
|||
@AppStorage("holdSpeedPlayer") private var holdSpeedPlayer: Double = 2.0
|
||||
@AppStorage("skipIncrement") private var skipIncrement: Double = 10.0
|
||||
@AppStorage("skipIncrementHold") private var skipIncrementHold: Double = 30.0
|
||||
@AppStorage("holdForPauseEnabled") private var holdForPauseEnabled = false
|
||||
|
||||
private let mediaPlayers = ["Default", "VLC", "OutPlayer", "Infuse", "nPlayer", "Sora"]
|
||||
|
||||
|
|
@ -40,6 +41,9 @@ struct SettingsViewPlayer: View {
|
|||
|
||||
Toggle("Force Landscape", isOn: $isAlwaysLandscape)
|
||||
.tint(.accentColor)
|
||||
|
||||
Toggle("Two finger hold for pause",isOn: $holdForPauseEnabled)
|
||||
.tint(.accentColor)
|
||||
}
|
||||
|
||||
Section(header: Text("Speed Settings")) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue