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:
Toni Förster
2023-12-04 14:47:26 +01:00
parent 600b8d198b
commit 0d9c27319d
3 changed files with 18 additions and 6 deletions

View File

@@ -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)
}
}