Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/Database/TPStreamsDownloadManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public final class TPStreamsDownloadManager {
on viewController: UIViewController,
completion: ((Result<OfflineAsset, TPDownloadError>) -> Void)?
) {
let alert = UIAlertController(title: "Select Download Quality", message: nil, preferredStyle: .actionSheet)
let alert = UIAlertController(title: "Select Download Quality", message: "Video quality adjusts based on your internet speed. Your selection sets the highest possible quality.", preferredStyle: .actionSheet)

for quality in qualities {
alert.addAction(UIAlertAction(title: quality.resolution, style: .default) { _ in
Expand Down
7 changes: 7 additions & 0 deletions Source/Utils/VideoQualityUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ extension VideoQuality {
}

public class VideoQualityUtils {
public static func getDisplayLabel(for quality: VideoQuality) -> String {
guard quality.resolution != "Auto" else {
return "Auto"
}
return "Up to \(quality.resolution)"
}

public static func selectClosestQuality(
in qualities: [VideoQuality],
for resolution: String,
Expand Down
10 changes: 6 additions & 4 deletions Source/Views/SwiftUI/PlayerSettingsButton.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ struct PlayerSettingsButton: View {
case .videoQuality:
return ActionSheet(
title: Text("Video Quality"),
message: nil,
message: Text("Video quality adjusts based on your internet speed. Your selection sets the highest possible quality."),
buttons: videoQualityOptions() + [.cancel()]
)
case .downloadQuality:
return ActionSheet(
title: Text("Download Quality"),
message: nil,
message: Text("Video quality adjusts based on your internet speed. Your selection sets the highest possible quality."),
buttons: downloadQualityOptions() + [.cancel()]
)
}
Expand Down Expand Up @@ -95,7 +95,9 @@ struct PlayerSettingsButton: View {
}

private func videoQualityButton() -> ActionSheet.Button {
return .default(Text("Video Quality - \(player.currentVideoQuality?.resolution ?? "Auto")")) {
let currentLabel = player.currentVideoQuality.map { VideoQualityUtils.getDisplayLabel(for: $0) } ?? "Auto"

return .default(Text("Video Quality - \(currentLabel)")) {
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
self.showOptions = true
self.currentMenu = .videoQuality
Expand Down Expand Up @@ -123,7 +125,7 @@ struct PlayerSettingsButton: View {

private func videoQualityOptions() -> [ActionSheet.Button] {
return player.availableVideoQualities.map { videoQuality in
.default(Text(videoQuality.resolution)) {
.default(Text(VideoQualityUtils.getDisplayLabel(for: videoQuality))) {
player.changeVideoQuality(videoQuality)
}
}
Expand Down
7 changes: 4 additions & 3 deletions Source/Views/UIKit/PlayerControlsUIView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ class PlayerControlsUIView: UIView {
}

func createVideoQualityMenu() -> UIAlertController {
let qualityMenu = UIAlertController(title: "Available resolutions", message: nil, preferredStyle: ACTION_SHEET_PREFERRED_STYLE)
let qualityMenu = UIAlertController(title: "Available resolutions", message: "Video quality adjusts based on your internet speed. Your selection sets the highest possible quality.", preferredStyle: ACTION_SHEET_PREFERRED_STYLE)
for quality in self.player.availableVideoQualities {
let action = createActionForVideoQuality(quality)
qualityMenu.addAction(action)
Expand All @@ -219,7 +219,7 @@ class PlayerControlsUIView: UIView {
}

func createDownloadQualityMenu() -> UIAlertController {
let qualityMenu = UIAlertController(title: "Available resolutions", message: nil, preferredStyle: ACTION_SHEET_PREFERRED_STYLE)
let qualityMenu = UIAlertController(title: "Available resolutions", message: "Video quality adjusts based on your internet speed. Your selection sets the highest possible quality.", preferredStyle: ACTION_SHEET_PREFERRED_STYLE)
var availableVideoQualities = player.availableVideoQualities
// Remove Auto Quality from the Array
availableVideoQualities.remove(at: 0)
Expand All @@ -243,7 +243,8 @@ class PlayerControlsUIView: UIView {
}

func createActionForVideoQuality(_ quality: VideoQuality) -> UIAlertAction {
let action = UIAlertAction(title: quality.resolution, style: .default, handler: { (_) in
let label = VideoQualityUtils.getDisplayLabel(for: quality)
let action = UIAlertAction(title: label, style: .default, handler: { (_) in
self.player.changeVideoQuality(quality)
})

Expand Down
Loading