Add setting for closing player after playing last item (fix #98)

This commit is contained in:
Arkadiusz Fal
2022-06-25 15:14:16 +02:00
parent c940fb3198
commit 17787fa69c
7 changed files with 44 additions and 20 deletions

View File

@@ -464,20 +464,24 @@ final class AVPlayerBackend: PlayerBackend {
}
@objc func itemDidPlayToEndTime() {
model.prepareCurrentItemForHistory(finished: true)
if Defaults[.closeLastItemOnPlaybackEnd] {
model.prepareCurrentItemForHistory(finished: true)
}
if model.queue.isEmpty {
#if !os(macOS)
try? AVAudioSession.sharedInstance().setActive(false)
#endif
model.resetQueue()
#if os(tvOS)
controller?.playerView.dismiss(animated: false) { [weak self] in
self?.controller?.dismiss(animated: true)
}
#else
model.hide()
#endif
if Defaults[.closeLastItemOnPlaybackEnd] {
model.resetQueue()
#if os(tvOS)
controller?.playerView.dismiss(animated: false) { [weak self] in
self?.controller?.dismiss(animated: true)
}
#else
model.hide()
#endif
}
} else {
if model.playingInPictureInPicture {
startPictureInPictureOnPlay = true