mirror of
https://github.com/yattee/yattee.git
synced 2024-11-09 15:58:20 +00:00
make time updates work for .mpv and .avp
- time update notifications work for both backends - only init mpv timers when mpv is the active backend - move notification extension to playerbackend
This commit is contained in:
parent
600b8d198b
commit
0d9c27319d
@ -116,6 +116,10 @@ final class AVPlayerBackend: PlayerBackend {
|
||||
#endif
|
||||
}
|
||||
|
||||
deinit {
|
||||
NotificationCenter.default.removeObserver(self, name: .getTimeUpdatesNotification, object: self.currentTime)
|
||||
}
|
||||
|
||||
func bestPlayable(_ streams: [Stream], maxResolution: ResolutionSetting) -> Stream? {
|
||||
let sortedByResolution = streams
|
||||
.filter { ($0.kind == .adaptive || $0.kind == .stream) && $0.resolution <= maxResolution.value }
|
||||
@ -596,6 +600,8 @@ final class AVPlayerBackend: PlayerBackend {
|
||||
if self.controlsUpdates {
|
||||
self.updateControls()
|
||||
}
|
||||
|
||||
NotificationCenter.default.post(name: .getTimeUpdatesNotification, object: self.currentTime)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -183,11 +183,17 @@ final class MPVBackend: PlayerBackend {
|
||||
|
||||
init() {
|
||||
clientTimer = .init(interval: .seconds(Self.timeUpdateInterval), mode: .infinite) { [weak self] _ in
|
||||
self?.getTimeUpdates()
|
||||
guard let self = self, self.model.activeBackend == .mpv else {
|
||||
return
|
||||
}
|
||||
self.getTimeUpdates()
|
||||
}
|
||||
|
||||
networkStateTimer = .init(interval: .seconds(Self.networkStateUpdateInterval), mode: .infinite) { [weak self] _ in
|
||||
self?.updateNetworkState()
|
||||
guard let self = self, self.model.activeBackend == .mpv else {
|
||||
return
|
||||
}
|
||||
self.updateNetworkState()
|
||||
}
|
||||
}
|
||||
|
||||
@ -624,7 +630,3 @@ final class MPVBackend: PlayerBackend {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension Notification.Name {
|
||||
static let getTimeUpdatesNotification = Notification.Name("getTimeUpdatesNotification")
|
||||
}
|
||||
|
@ -154,3 +154,7 @@ extension PlayerBackend {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extension Notification.Name {
|
||||
static let getTimeUpdatesNotification = Notification.Name("getTimeUpdatesNotification")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user