mirror of
https://github.com/yattee/yattee.git
synced 2024-11-10 00:08:21 +00:00
Add "Pause when entering background" option (#198)
This commit is contained in:
parent
12e427bcb8
commit
f10aa1abd9
@ -522,7 +522,7 @@ final class PlayerModel: ObservableObject {
|
||||
}
|
||||
#else
|
||||
func handleEnterForeground() {
|
||||
setNeedsDrawing(true)
|
||||
setNeedsDrawing(presentingPlayer)
|
||||
|
||||
guard closePiPAndOpenPlayerOnEnteringForeground, playingInPictureInPicture else {
|
||||
return
|
||||
@ -534,7 +534,8 @@ final class PlayerModel: ObservableObject {
|
||||
|
||||
func handleEnterBackground() {
|
||||
setNeedsDrawing(false)
|
||||
if !playingInPictureInPicture, !musicMode {
|
||||
|
||||
if Defaults[.pauseOnEnteringBackground], !playingInPictureInPicture, !musicMode {
|
||||
pause()
|
||||
}
|
||||
}
|
||||
|
@ -64,6 +64,9 @@ extension Defaults.Keys {
|
||||
static let commentsPlacement = Key<CommentsPlacement>("commentsPlacement", default: .separate)
|
||||
#endif
|
||||
static let pauseOnHidingPlayer = Key<Bool>("pauseOnHidingPlayer", default: defaultForPauseOnHidingPlayer)
|
||||
#if !os(macOS)
|
||||
static let pauseOnEnteringBackground = Key<Bool>("pauseOnEnteringBackground", default: true)
|
||||
#endif
|
||||
static let closeLastItemOnPlaybackEnd = Key<Bool>("closeLastItemOnPlaybackEnd", default: false)
|
||||
|
||||
static let closePiPOnNavigation = Key<Bool>("closePiPOnNavigation", default: false)
|
||||
|
@ -20,6 +20,7 @@ struct PlayerSettings: View {
|
||||
@Default(.closePiPOnNavigation) private var closePiPOnNavigation
|
||||
@Default(.closePiPOnOpeningPlayer) private var closePiPOnOpeningPlayer
|
||||
#if !os(macOS)
|
||||
@Default(.pauseOnEnteringBackground) private var pauseOnEnteringBackground
|
||||
@Default(.closePiPAndOpenPlayerOnEnteringForeground) private var closePiPAndOpenPlayerOnEnteringForeground
|
||||
#endif
|
||||
|
||||
@ -59,6 +60,9 @@ struct PlayerSettings: View {
|
||||
sourcePicker
|
||||
qualityPicker
|
||||
pauseOnHidingPlayerToggle
|
||||
#if !os(macOS)
|
||||
pauseOnEnteringBackgroundToogle
|
||||
#endif
|
||||
closeLastItemOnPlaybackEndToggle
|
||||
}
|
||||
|
||||
@ -190,6 +194,12 @@ struct PlayerSettings: View {
|
||||
Toggle("Pause when player is closed", isOn: $pauseOnHidingPlayer)
|
||||
}
|
||||
|
||||
#if !os(macOS)
|
||||
private var pauseOnEnteringBackgroundToogle: some View {
|
||||
Toggle("Pause when entering background", isOn: $pauseOnEnteringBackground)
|
||||
}
|
||||
#endif
|
||||
|
||||
private var closeLastItemOnPlaybackEndToggle: some View {
|
||||
Toggle("Close video after playing last in the queue", isOn: $closeLastItemOnPlaybackEnd)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user