From 0716602e3ff7881234497319eadb1b6e53501be8 Mon Sep 17 00:00:00 2001 From: Arkadiusz Fal Date: Mon, 11 Jul 2022 18:30:12 +0200 Subject: [PATCH] Minor fixes --- Model/Player/PlayerControlsModel.swift | 17 +++++++++++++---- Shared/Player/Controls/ControlsOverlay.swift | 6 +++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Model/Player/PlayerControlsModel.swift b/Model/Player/PlayerControlsModel.swift index f8d10753..e333be07 100644 --- a/Model/Player/PlayerControlsModel.swift +++ b/Model/Player/PlayerControlsModel.swift @@ -1,5 +1,6 @@ import Combine import CoreMedia +import Defaults import Foundation import SwiftUI @@ -7,8 +8,8 @@ final class PlayerControlsModel: ObservableObject { @Published var isLoadingVideo = false @Published var isPlaying = true @Published var presentingControls = false { didSet { handlePresentationChange() } } - @Published var presentingControlsOverlay = false { didSet { handleOverlayPresentationChange() } } - @Published var presentingDetailsOverlay = false + @Published var presentingControlsOverlay = false { didSet { handleSettingsOverlayPresentationChange() } } + @Published var presentingDetailsOverlay = false { didSet { handleDetailsOverlayPresentationChange() } } @Published var timer: Timer? #if os(tvOS) @@ -49,8 +50,8 @@ final class PlayerControlsModel: ObservableObject { } } - func handleOverlayPresentationChange() { - player?.backend.setNeedsNetworkStateUpdates(presentingControlsOverlay) + func handleSettingsOverlayPresentationChange() { + player?.backend.setNeedsNetworkStateUpdates(presentingControlsOverlay && Defaults[.showMPVPlaybackStats]) if presentingControlsOverlay { removeTimer() } else { @@ -58,6 +59,14 @@ final class PlayerControlsModel: ObservableObject { } } + func handleDetailsOverlayPresentationChange() { + if presentingDetailsOverlay { + removeTimer() + } else { + resetTimer() + } + } + var presentingOverlays: Bool { presentingDetailsOverlay || presentingControlsOverlay } diff --git a/Shared/Player/Controls/ControlsOverlay.swift b/Shared/Player/Controls/ControlsOverlay.swift index 6ce4cb51..8968f13f 100644 --- a/Shared/Player/Controls/ControlsOverlay.swift +++ b/Shared/Player/Controls/ControlsOverlay.swift @@ -15,7 +15,11 @@ struct ControlsOverlay: View { backendButtons } qualityButton - captionsButton + + if player.activeBackend == .mpv { + captionsButton + } + HStack { decreaseRateButton rateButton