From 64a18678ce69ed75aacb59f97c20ef7511618a2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toni=20F=C3=B6rster?= Date: Mon, 27 Nov 2023 23:49:18 +0100 Subject: [PATCH 1/2] add option to exit fullscreen on end --- Model/Player/Backends/PlayerBackend.swift | 21 +++++++++++++++------ Shared/Settings/PlayerSettings.swift | 11 +++++++++++ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/Model/Player/Backends/PlayerBackend.swift b/Model/Player/Backends/PlayerBackend.swift index 18c6ca3d..331a0bfb 100644 --- a/Model/Player/Backends/PlayerBackend.swift +++ b/Model/Player/Backends/PlayerBackend.swift @@ -111,15 +111,24 @@ extension PlayerBackend { model.prepareCurrentItemForHistory(finished: true) if model.queue.isEmpty { - if Defaults[.closeVideoOnEOF] { - #if os(tvOS) + #if os(tvOS) + if Defaults[.closeVideoOnEOF] { if model.activeBackend == .appleAVPlayer { model.avPlayerBackend.controller?.dismiss(animated: false) } - #endif - model.resetQueue() - model.hide() - } + model.resetQueue() + model.hide() + } + #else + if Defaults[.closeVideoOnEOF] { + model.resetQueue() + model.hide() + } + + if !Defaults[.closeVideoOnEOF], Defaults[.exitFullscreenOnEOF], model.playingFullScreen { + model.exitFullScreen() + } + #endif } else { model.advanceToNextItem() } diff --git a/Shared/Settings/PlayerSettings.swift b/Shared/Settings/PlayerSettings.swift index 9c1aefdc..e9ff7839 100644 --- a/Shared/Settings/PlayerSettings.swift +++ b/Shared/Settings/PlayerSettings.swift @@ -11,6 +11,7 @@ struct PlayerSettings: View { #if !os(tvOS) @Default(.showScrollToTopInComments) private var showScrollToTopInComments @Default(.collapsedLinesDescription) private var collapsedLinesDescription + @Default(.exitFullscreenOnEOF) private var exitFullscreenOnEOF #endif @Default(.expandVideoDescription) private var expandVideoDescription @Default(.pauseOnHidingPlayer) private var pauseOnHidingPlayer @@ -85,6 +86,9 @@ struct PlayerSettings: View { } pauseOnHidingPlayerToggle closeVideoOnEOFToggle + #if !os(tvOS) + exitFullscreenOnEOFToggle + #endif #if !os(macOS) pauseOnEnteringBackgroundToogle #endif @@ -294,6 +298,13 @@ struct PlayerSettings: View { Toggle("Close video and player on end", isOn: $closeVideoOnEOF) } + #if !os(tvOS) + private var exitFullscreenOnEOFToggle: some View { + Toggle("Exit fullscreen on end", isOn: $exitFullscreenOnEOF) + .disabled(closeVideoOnEOF) + } + #endif + #if !os(macOS) private var pauseOnEnteringBackgroundToogle: some View { Toggle("Pause when entering background", isOn: $pauseOnEnteringBackground) From 8e97d3f42f7ba295dba9d6a0d8c32afd0cb09578 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toni=20F=C3=B6rster?= Date: Tue, 20 Aug 2024 22:56:55 +0200 Subject: [PATCH 2/2] set playingFullscreen to proper value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Toni Förster --- .../Exporters/PlayerSettingsGroupExporter.swift | 1 + .../Importers/PlayerSettingsGroupImporter.swift | 4 ++++ Model/Player/Backends/PlayerBackend.swift | 4 +--- Model/Player/PlayerModel.swift | 2 ++ Shared/Defaults.swift | 1 + 5 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Model/Import Export Settings/Exporters/PlayerSettingsGroupExporter.swift b/Model/Import Export Settings/Exporters/PlayerSettingsGroupExporter.swift index 8c2abf95..5acf048b 100644 --- a/Model/Import Export Settings/Exporters/PlayerSettingsGroupExporter.swift +++ b/Model/Import Export Settings/Exporters/PlayerSettingsGroupExporter.swift @@ -7,6 +7,7 @@ final class PlayerSettingsGroupExporter: SettingsGroupExporter { "playerInstanceID": Defaults[.playerInstanceID] ?? "", "pauseOnHidingPlayer": Defaults[.pauseOnHidingPlayer], "closeVideoOnEOF": Defaults[.closeVideoOnEOF], + "exitFullscreenOnEOF": Defaults[.exitFullscreenOnEOF], "expandVideoDescription": Defaults[.expandVideoDescription], "collapsedLinesDescription": Defaults[.collapsedLinesDescription], "showChapters": Defaults[.showChapters], diff --git a/Model/Import Export Settings/Importers/PlayerSettingsGroupImporter.swift b/Model/Import Export Settings/Importers/PlayerSettingsGroupImporter.swift index 3f9375fe..b05e30fd 100644 --- a/Model/Import Export Settings/Importers/PlayerSettingsGroupImporter.swift +++ b/Model/Import Export Settings/Importers/PlayerSettingsGroupImporter.swift @@ -17,6 +17,10 @@ struct PlayerSettingsGroupImporter { Defaults[.closeVideoOnEOF] = closeVideoOnEOF } + if let exitFullscreenOnEOF = json["exitFullscreenOnEOF"].bool { + Defaults[.exitFullscreenOnEOF] = exitFullscreenOnEOF + } + if let expandVideoDescription = json["expandVideoDescription"].bool { Defaults[.expandVideoDescription] = expandVideoDescription } diff --git a/Model/Player/Backends/PlayerBackend.swift b/Model/Player/Backends/PlayerBackend.swift index 331a0bfb..96cd69cb 100644 --- a/Model/Player/Backends/PlayerBackend.swift +++ b/Model/Player/Backends/PlayerBackend.swift @@ -123,9 +123,7 @@ extension PlayerBackend { if Defaults[.closeVideoOnEOF] { model.resetQueue() model.hide() - } - - if !Defaults[.closeVideoOnEOF], Defaults[.exitFullscreenOnEOF], model.playingFullScreen { + } else if Defaults[.exitFullscreenOnEOF], model.playingFullScreen { model.exitFullScreen() } #endif diff --git a/Model/Player/PlayerModel.swift b/Model/Player/PlayerModel.swift index 941694bf..2fe1e30c 100644 --- a/Model/Player/PlayerModel.swift +++ b/Model/Player/PlayerModel.swift @@ -1001,6 +1001,7 @@ final class PlayerModel: ObservableObject { logger.info("entering fullscreen") toggleFullscreen(false, showControls: showControls) + self.playingFullScreen = true } func exitFullScreen(showControls: Bool = true) { @@ -1008,6 +1009,7 @@ final class PlayerModel: ObservableObject { logger.info("exiting fullscreen") toggleFullscreen(true, showControls: showControls) + self.playingFullScreen = false } func updateNowPlayingInfo() { diff --git a/Shared/Defaults.swift b/Shared/Defaults.swift index f7b7415f..4f65acde 100644 --- a/Shared/Defaults.swift +++ b/Shared/Defaults.swift @@ -75,6 +75,7 @@ extension Defaults.Keys { static let expandVideoDescription = Key("expandVideoDescription", default: expandVideoDescriptionDefault) static let collapsedLinesDescription = Key("collapsedLinesDescription", default: 5) + static let exitFullscreenOnEOF = Key("exitFullscreenOnEOF", default: true) static let showChapters = Key("showChapters", default: true) static let showChapterThumbnails = Key("showChapterThumbnails", default: true)