subscribe chapters to currentTime notification

This commit is contained in:
Toni Förster
2023-12-04 00:07:39 +01:00
parent aa5d6733b2
commit 586cea7d44
2 changed files with 18 additions and 7 deletions

View File

@@ -191,6 +191,10 @@ final class MPVBackend: PlayerBackend {
}
}
deinit {
NotificationCenter.default.removeObserver(self, name: .getTimeUpdatesNotification, object: self.currentTime)
}
typealias AreInIncreasingOrder = (Stream, Stream) -> Bool
func bestPlayable(_ streams: [Stream], maxResolution: ResolutionSetting) -> Stream? {
@@ -432,6 +436,8 @@ final class MPVBackend: PlayerBackend {
timeObserverThrottle.execute {
self.model.updateWatch(time: self.currentTime)
}
NotificationCenter.default.post(name: .getTimeUpdatesNotification, object: self.currentTime)
}
private func stopClientUpdates() {
@@ -618,3 +624,7 @@ final class MPVBackend: PlayerBackend {
}
}
}
extension Notification.Name {
static let getTimeUpdatesNotification = Notification.Name("getTimeUpdatesNotification")
}