Skip to content

Commit

Permalink
move MP4 to the bottom and hide disabled formats
Browse files Browse the repository at this point in the history
Currently, mp4 is one of the first formats chosen. But there are some issues when it comes to scrubbing/seeking. Therefore we only use mp4 as the last resort, this should give a better user experience.

sort of fixes yattee#590 & yattee#626 & yattee#487

Also when choosing the AVPlayer in the Quality settings, disabled formats are hidden.
  • Loading branch information
stonerl committed Apr 26, 2024
1 parent d1cf45c commit 581cebd
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 31 deletions.
10 changes: 5 additions & 5 deletions Model/QualityProfile.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ struct QualityProfile: Hashable, Identifiable, Defaults.Serializable {
enum Format: String, CaseIterable, Identifiable, Defaults.Serializable {
case hls
case stream
case mp4
case avc1
case av1
case webm
case mp4

var id: String {
rawValue
Expand All @@ -35,14 +35,14 @@ struct QualityProfile: Hashable, Identifiable, Defaults.Serializable {
return nil
case .stream:
return nil
case .mp4:
return .mp4
case .webm:
return .webm
case .avc1:
return .avc1
case .av1:
return .av1
case .webm:
return .webm
case .mp4:
return .mp4
}
}
}
Expand Down
16 changes: 8 additions & 8 deletions Model/Stream.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,21 +83,21 @@ class Stream: Equatable, Hashable, Identifiable {
}

enum Format: String, Comparable {
case webm
case avc1
case av1
case webm
case mp4
case unknown

private var sortOrder: Int {
switch self {
case .mp4:
return 0
case .avc1:
return 1
return 0
case .av1:
return 2
return 1
case .webm:
return 2
case .mp4:
return 3
case .unknown:
return 4
Expand All @@ -121,15 +121,15 @@ class Stream: Equatable, Hashable, Identifiable {
static func from(_ string: String) -> Self {
let lowercased = string.lowercased()

if lowercased.contains("webm") {
return .webm
}
if lowercased.contains("avc1") {
return .avc1
}
if lowercased.contains("av01") {
return .av1
}
if lowercased.contains("webm") {
return .webm
}
if lowercased.contains("mpeg_4") || lowercased.contains("mp4") {
return .mp4
}
Expand Down
32 changes: 14 additions & 18 deletions Shared/Settings/QualityProfileForm.swift
Original file line number Diff line number Diff line change
Expand Up @@ -199,17 +199,21 @@ struct QualityProfileForm: View {
#endif
}

var filteredFormatList: some View {
ForEach(QualityProfile.Format.allCases.filter { !isFormatDisabled($0) }, id: \.self) { format in
MultiselectRow(
title: format.description,
selected: isFormatSelected(format),
disabled: isFormatDisabled(format)
) { value in
toggleFormat(format, value: value)
}
}
}

@ViewBuilder var formatsPicker: some View {
#if os(macOS)
let list = ForEach(QualityProfile.Format.allCases, id: \.self) { format in
MultiselectRow(
title: format.description,
selected: isFormatSelected(format),
disabled: isFormatDisabled(format)
) { value in
toggleFormat(format, value: value)
}
}
let list = filteredFormatList

Group {
if #available(macOS 12.0, *) {
Expand All @@ -222,15 +226,7 @@ struct QualityProfileForm: View {
}
Spacer()
#else
ForEach(QualityProfile.Format.allCases, id: \.self) { format in
MultiselectRow(
title: format.description,
selected: isFormatSelected(format),
disabled: isFormatDisabled(format)
) { value in
toggleFormat(format, value: value)
}
}
filteredFormatList
#endif
}

Expand Down

0 comments on commit 581cebd

Please sign in to comment.