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,13 +110,15 @@ extension PlayerBackend {
model.prepareCurrentItemForHistory(finished: true)
if model.queue.isEmpty {
#if os(tvOS)
if model.activeBackend == .appleAVPlayer {
model.avPlayerBackend.controller?.dismiss(animated: false)
}
#endif
model.resetQueue()
model.hide()
if Defaults[.closeVideoOnEOF] {
#if os(tvOS)
if model.activeBackend == .appleAVPlayer {
model.avPlayerBackend.controller?.dismiss(animated: false)
}
#endif
model.resetQueue()
model.hide()
}
} else {
model.advanceToNextItem()
}

View File

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

View File

@ -13,6 +13,7 @@ struct PlayerSettings: View {
#endif
@Default(.expandVideoDescription) private var expandVideoDescription
@Default(.pauseOnHidingPlayer) private var pauseOnHidingPlayer
@Default(.closeVideoOnEOF) private var closeVideoOnEOF
#if os(iOS)
@Default(.honorSystemOrientationLock) private var honorSystemOrientationLock
@Default(.enterFullscreenInLandscape) private var enterFullscreenInLandscape
@ -66,6 +67,7 @@ struct PlayerSettings: View {
sourcePicker
}
pauseOnHidingPlayerToggle
closeVideoOnEOFToggle
#if !os(macOS)
pauseOnEnteringBackgroundToogle
#endif
@ -192,6 +194,10 @@ struct PlayerSettings: View {
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)
private var pauseOnEnteringBackgroundToogle: some View {
Toggle("Pause when entering background", isOn: $pauseOnEnteringBackground)

View File

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