Merge pull request #1512 from complacentsee/ios_autorewind

IOS: Support autoRewind and disableAutoRewind setting
This commit is contained in:
advplyr
2025-03-12 17:12:58 -05:00
committed by GitHub
3 changed files with 54 additions and 27 deletions
@@ -21,27 +21,27 @@ class PlayerTimeUtils {
static internal func timeSinceLastPlayed(_ lastPlayedMs: Double?) -> TimeInterval? {
guard let lastPlayedMs = lastPlayedMs else { return nil }
let lastPlayed = Date(timeIntervalSince1970: lastPlayedMs / 1000)
return lastPlayed.timeIntervalSinceNow
return Date().timeIntervalSince(lastPlayed)
}
static internal func timeToSeekBackForSinceLastPlayed(_ sinceLastPlayed: TimeInterval?) -> TimeInterval {
if isAutoRewindDisabled(){
return 0
}
if let sinceLastPlayed = sinceLastPlayed {
if sinceLastPlayed < 6 {
return 2
} else if sinceLastPlayed < 12 {
return 10
} else if sinceLastPlayed < 30 {
return 15
} else if sinceLastPlayed < 180 {
return 20
} else if sinceLastPlayed < 3600 {
return 25
} else {
return 29
}
if sinceLastPlayed < 10 { return 0 } // 10s or less = no seekback
else if sinceLastPlayed < 60 { return 3 } // 10s to 1m = jump back 3s
else if sinceLastPlayed < 300 { return 10 } // 1m to 5m = jump back 10s
else if sinceLastPlayed < 1800 { return 20 } // 5m to 30m = jump back 20s
else { return 30 } // 30m and up = jump back 30s
} else {
return 5
return 0
}
}
static internal func isAutoRewindDisabled() -> Bool {
let deviceSettings = Database.shared.getDeviceSettings()
return deviceSettings.disableAutoRewind
}
}