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