Add option "Close player on end of video"

Fix #442
This commit is contained in:
Arkadiusz Fal 2023-05-21 12:33:59 +02:00
parent c6798be167
commit 7d7bd40a89
4 changed files with 17 additions and 8 deletions

View File

@ -110,6 +110,7 @@ extension PlayerBackend {
model.prepareCurrentItemForHistory(finished: true) model.prepareCurrentItemForHistory(finished: true)
if model.queue.isEmpty { if model.queue.isEmpty {
if Defaults[.closeVideoOnEOF] {
#if os(tvOS) #if os(tvOS)
if model.activeBackend == .appleAVPlayer { if model.activeBackend == .appleAVPlayer {
model.avPlayerBackend.controller?.dismiss(animated: false) model.avPlayerBackend.controller?.dismiss(animated: false)
@ -117,6 +118,7 @@ extension PlayerBackend {
#endif #endif
model.resetQueue() model.resetQueue()
model.hide() model.hide()
}
} else { } else {
model.advanceToNextItem() model.advanceToNextItem()
} }

View File

@ -158,6 +158,7 @@ extension Defaults.Keys {
#if !os(macOS) #if !os(macOS)
static let pauseOnEnteringBackground = Key<Bool>("pauseOnEnteringBackground", default: true) static let pauseOnEnteringBackground = Key<Bool>("pauseOnEnteringBackground", default: true)
#endif #endif
static let closeVideoOnEOF = Key<Bool>("closeVideoOnEOF", default: false)
static let closePiPOnNavigation = Key<Bool>("closePiPOnNavigation", default: false) static let closePiPOnNavigation = Key<Bool>("closePiPOnNavigation", default: false)
static let closePiPOnOpeningPlayer = Key<Bool>("closePiPOnOpeningPlayer", default: false) static let closePiPOnOpeningPlayer = Key<Bool>("closePiPOnOpeningPlayer", default: false)
#if !os(macOS) #if !os(macOS)

View File

@ -13,6 +13,7 @@ struct PlayerSettings: View {
#endif #endif
@Default(.expandVideoDescription) private var expandVideoDescription @Default(.expandVideoDescription) private var expandVideoDescription
@Default(.pauseOnHidingPlayer) private var pauseOnHidingPlayer @Default(.pauseOnHidingPlayer) private var pauseOnHidingPlayer
@Default(.closeVideoOnEOF) private var closeVideoOnEOF
#if os(iOS) #if os(iOS)
@Default(.honorSystemOrientationLock) private var honorSystemOrientationLock @Default(.honorSystemOrientationLock) private var honorSystemOrientationLock
@Default(.enterFullscreenInLandscape) private var enterFullscreenInLandscape @Default(.enterFullscreenInLandscape) private var enterFullscreenInLandscape
@ -66,6 +67,7 @@ struct PlayerSettings: View {
sourcePicker sourcePicker
} }
pauseOnHidingPlayerToggle pauseOnHidingPlayerToggle
closeVideoOnEOFToggle
#if !os(macOS) #if !os(macOS)
pauseOnEnteringBackgroundToogle pauseOnEnteringBackgroundToogle
#endif #endif
@ -192,6 +194,10 @@ struct PlayerSettings: View {
Toggle("Pause when player is closed", isOn: $pauseOnHidingPlayer) Toggle("Pause when player is closed", isOn: $pauseOnHidingPlayer)
} }
private var closeVideoOnEOFToggle: some View {
Toggle("Close video and player on end", isOn: $closeVideoOnEOF)
}
#if !os(macOS) #if !os(macOS)
private var pauseOnEnteringBackgroundToogle: some View { private var pauseOnEnteringBackgroundToogle: some View {
Toggle("Pause when entering background", isOn: $pauseOnEnteringBackground) Toggle("Pause when entering background", isOn: $pauseOnEnteringBackground)

View File

@ -245,7 +245,7 @@ struct SettingsView: View {
case .browsing: case .browsing:
return 880 return 880
case .player: case .player:
return 450 return 480
case .controls: case .controls:
return 920 return 920
case .quality: case .quality: