mirror of
https://github.com/yattee/yattee.git
synced 2025-08-09 20:24:06 +00:00
Don't autoplay last video at start
This commit is contained in:
@@ -50,49 +50,16 @@ final class PlayerModel: ObservableObject {
|
||||
|
||||
private var statusObservation: NSKeyValueObservation?
|
||||
|
||||
var autoPlayItems = false
|
||||
|
||||
init(accounts: AccountsModel? = nil, instances: InstancesModel? = nil) {
|
||||
self.accounts = accounts ?? AccountsModel()
|
||||
self.instances = instances ?? InstancesModel()
|
||||
|
||||
addItemDidPlayToEndTimeObserver()
|
||||
addFrequentTimeObserver()
|
||||
addInfrequentTimeObserver()
|
||||
addPlayerTimeControlStatusObserver()
|
||||
}
|
||||
|
||||
func loadHistoryDetails() {
|
||||
guard !accounts.current.isNil else {
|
||||
return
|
||||
}
|
||||
|
||||
queue = Defaults[.queue]
|
||||
queue.forEach { item in
|
||||
accounts.api.loadDetails(item) { newItem in
|
||||
if let index = self.queue.firstIndex(where: { $0.id == item.id }) {
|
||||
self.queue[index] = newItem
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
history = Defaults[.history]
|
||||
history.forEach { item in
|
||||
accounts.api.loadDetails(item) { newItem in
|
||||
if let index = self.history.firstIndex(where: { $0.id == item.id }) {
|
||||
self.history[index] = newItem
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let item = Defaults[.lastPlayed] {
|
||||
accounts.api.loadDetails(item) { [weak self] newItem in
|
||||
self?.playNow(newItem.video, at: newItem.playbackTime?.seconds)
|
||||
}
|
||||
} else {
|
||||
autoPlayItems = true
|
||||
}
|
||||
}
|
||||
|
||||
func presentPlayer() {
|
||||
presentingPlayer = true
|
||||
}
|
||||
@@ -193,15 +160,7 @@ final class PlayerModel: ObservableObject {
|
||||
#endif
|
||||
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.3) { [weak self] in
|
||||
guard let self = self else {
|
||||
return
|
||||
}
|
||||
|
||||
guard self.autoPlayItems else {
|
||||
return
|
||||
}
|
||||
|
||||
self.play()
|
||||
self?.play()
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user