Remove Watch Next

This commit is contained in:
Arkadiusz Fal
2023-04-22 13:56:25 +02:00
parent 67690bc435
commit 28f346dee2
14 changed files with 21 additions and 727 deletions

View File

@@ -105,47 +105,27 @@ extension PlayerBackend {
return
}
let action = {
switch model.playbackMode {
case .queue, .shuffle:
model.prepareCurrentItemForHistory(finished: true)
switch model.playbackMode {
case .queue, .shuffle:
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()
} else {
model.advanceToNextItem()
}
case .loopOne:
loopAction()
case .related:
guard let item = model.autoplayItem else { return }
model.resetAutoplay()
model.advanceToItem(item)
}
}
let actionAndHideWatchNext: (Bool) -> Void = { delay in
WatchNextViewModel.shared.hide()
if delay {
Delay.by(0.3) {
action()
}
if model.queue.isEmpty {
#if os(tvOS)
if model.activeBackend == .appleAVPlayer {
model.avPlayerBackend.controller?.dismiss(animated: false)
}
#endif
model.resetQueue()
model.hide()
} else {
action()
model.advanceToNextItem()
}
}
if Defaults[.openWatchNextOnFinishedWatching], model.presentingPlayer {
let timer = Delay.by(TimeInterval(Defaults[.openWatchNextOnFinishedWatchingDelay]) ?? 5.0) {
actionAndHideWatchNext(true)
}
WatchNextViewModel.shared.finishedWatching(model.currentItem, timer: timer)
} else {
actionAndHideWatchNext(false)
case .loopOne:
loopAction()
case .related:
guard let item = model.autoplayItem else { return }
model.resetAutoplay()
model.advanceToItem(item)
}
}

View File

@@ -334,7 +334,6 @@ final class PlayerModel: ObservableObject {
pause()
videoBeingOpened = video
WatchNextViewModel.shared.hide()
navigation.presentingChannelSheet = false
var changeBackendHandler: (() -> Void)?

View File

@@ -14,7 +14,6 @@ extension PlayerModel {
}
func play(_ videos: [Video], shuffling: Bool = false) {
WatchNextViewModel.shared.hide()
navigation.presentingChannelSheet = false
playbackMode = shuffling ? .shuffle : .queue
@@ -59,7 +58,6 @@ extension PlayerModel {
comments.reset()
stream = nil
WatchNextViewModel.shared.hide()
navigation.presentingChannelSheet = false
withAnimation {
@@ -180,7 +178,6 @@ extension PlayerModel {
remove(newItem)
WatchNextViewModel.shared.hide()
navigation.presentingChannelSheet = false
currentItem = newItem
currentItem.playbackTime = time
@@ -229,7 +226,6 @@ extension PlayerModel {
withAnimation {
aspectRatio = VideoPlayerView.defaultAspectRatio
WatchNextViewModel.shared.hide()
navigation.presentingChannelSheet = false
currentItem = item
}