1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-14 06:10:32 +05:30

Remove best resolution setting

This commit is contained in:
Arkadiusz Fal 2022-08-15 00:16:02 +02:00
parent 4a5cdf2d03
commit 5e08d15b21
3 changed files with 6 additions and 14 deletions

View File

@ -4,7 +4,7 @@ import Foundation
struct QualityProfile: Hashable, Identifiable, Defaults.Serializable { struct QualityProfile: Hashable, Identifiable, Defaults.Serializable {
static var bridge = QualityProfileBridge() static var bridge = QualityProfileBridge()
static var defaultProfile = Self(id: "default", backend: .mpv, resolution: .hd720p60, formats: [.stream]) static var defaultProfile = Self(id: "default", backend: .mpv, resolution: .hd720p60, formats: [.stream])
static var highQualityProfile = Self(id: "highQuality", backend: .mpv, resolution: .best, formats: [.webm, .mp4, .av1, .avc1]) static var highQualityProfile = Self(id: "highQuality", backend: .mpv, resolution: .hd2160p60, formats: [.webm, .mp4, .av1, .avc1])
enum Format: String, CaseIterable, Identifiable, Defaults.Serializable { enum Format: String, CaseIterable, Identifiable, Defaults.Serializable {
case hls case hls
@ -65,7 +65,7 @@ struct QualityProfile: Hashable, Identifiable, Defaults.Serializable {
return true return true
} }
let resolutionMatch = !stream.resolution.isNil && (resolution == .best || (resolution.value >= stream.resolution)) let resolutionMatch = !stream.resolution.isNil && resolution.value >= stream.resolution
if resolutionMatch, formats.contains(.stream), stream.kind == .stream { if resolutionMatch, formats.contains(.stream), stream.kind == .stream {
return true return true

View File

@ -120,7 +120,6 @@ extension Defaults.Keys {
} }
enum ResolutionSetting: String, CaseIterable, Defaults.Serializable { enum ResolutionSetting: String, CaseIterable, Defaults.Serializable {
case best
case hd2160p60 case hd2160p60
case hd2160p30 case hd2160p30
case hd1440p60 case hd1440p60
@ -134,19 +133,12 @@ enum ResolutionSetting: String, CaseIterable, Defaults.Serializable {
case sd240p30 case sd240p30
case sd144p30 case sd144p30
var value: Stream.Resolution { var value: Stream.Resolution! {
switch self { .init(rawValue: rawValue)
case .best:
return .hd2160p60
default:
return Stream.Resolution(rawValue: rawValue)!
}
} }
var description: String { var description: String {
switch self { switch self {
case .best:
return "Best available quality"
case .hd2160p60: case .hd2160p60:
return "4K, 60fps" return "4K, 60fps"
case .hd2160p30: case .hd2160p30:

View File

@ -11,7 +11,7 @@ struct QualityProfileForm: View {
@State private var name = "" @State private var name = ""
@State private var backend = PlayerBackendType.mpv @State private var backend = PlayerBackendType.mpv
@State private var resolution = ResolutionSetting.best @State private var resolution = ResolutionSetting.hd1080p60
@State private var formats = [QualityProfile.Format]() @State private var formats = [QualityProfile.Format]()
var qualityProfile: QualityProfile! { var qualityProfile: QualityProfile! {
@ -270,7 +270,7 @@ struct QualityProfileForm: View {
func isResolutionDisabled(_ resolution: ResolutionSetting) -> Bool { func isResolutionDisabled(_ resolution: ResolutionSetting) -> Bool {
guard backend == .appleAVPlayer else { return false } guard backend == .appleAVPlayer else { return false }
return resolution != .best && resolution.value.height > 720 return resolution.value.height > 720
} }
func initializeForm() { func initializeForm() {