mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
no need for NotificationCenter
This commit is contained in:
parent
4ca8adc4dd
commit
721a97dc41
@ -116,10 +116,6 @@ final class AVPlayerBackend: PlayerBackend {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
deinit {
|
|
||||||
NotificationCenter.default.removeObserver(self, name: .getTimeUpdatesNotification, object: self.currentTime)
|
|
||||||
}
|
|
||||||
|
|
||||||
func bestPlayable(_ streams: [Stream], maxResolution: ResolutionSetting) -> Stream? {
|
func bestPlayable(_ streams: [Stream], maxResolution: ResolutionSetting) -> Stream? {
|
||||||
let sortedByResolution = streams
|
let sortedByResolution = streams
|
||||||
.filter { ($0.kind == .adaptive || $0.kind == .stream) && $0.resolution <= maxResolution.value }
|
.filter { ($0.kind == .adaptive || $0.kind == .stream) && $0.resolution <= maxResolution.value }
|
||||||
@ -601,7 +597,7 @@ final class AVPlayerBackend: PlayerBackend {
|
|||||||
self.updateControls()
|
self.updateControls()
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationCenter.default.post(name: .getTimeUpdatesNotification, object: self.currentTime)
|
self.model.updateTime(self.currentTime!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,6 +182,7 @@ final class MPVBackend: PlayerBackend {
|
|||||||
}
|
}
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
|
// swiftlint:disable shorthand_optional_binding
|
||||||
clientTimer = .init(interval: .seconds(Self.timeUpdateInterval), mode: .infinite) { [weak self] _ in
|
clientTimer = .init(interval: .seconds(Self.timeUpdateInterval), mode: .infinite) { [weak self] _ in
|
||||||
guard let self = self, self.model.activeBackend == .mpv else {
|
guard let self = self, self.model.activeBackend == .mpv else {
|
||||||
return
|
return
|
||||||
@ -195,10 +196,7 @@ final class MPVBackend: PlayerBackend {
|
|||||||
}
|
}
|
||||||
self.updateNetworkState()
|
self.updateNetworkState()
|
||||||
}
|
}
|
||||||
}
|
// swiftlint:enable shorthand_optional_binding
|
||||||
|
|
||||||
deinit {
|
|
||||||
NotificationCenter.default.removeObserver(self, name: .getTimeUpdatesNotification, object: self.currentTime)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
typealias AreInIncreasingOrder = (Stream, Stream) -> Bool
|
typealias AreInIncreasingOrder = (Stream, Stream) -> Bool
|
||||||
@ -443,7 +441,7 @@ final class MPVBackend: PlayerBackend {
|
|||||||
self.model.updateWatch(time: self.currentTime)
|
self.model.updateWatch(time: self.currentTime)
|
||||||
}
|
}
|
||||||
|
|
||||||
NotificationCenter.default.post(name: .getTimeUpdatesNotification, object: self.currentTime)
|
self.model.updateTime(self.currentTime!)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func stopClientUpdates() {
|
private func stopClientUpdates() {
|
||||||
|
@ -154,7 +154,3 @@ extension PlayerBackend {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extension Notification.Name {
|
|
||||||
static let getTimeUpdatesNotification = Notification.Name("getTimeUpdatesNotification")
|
|
||||||
}
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import CoreMedia
|
|
||||||
import Defaults
|
import Defaults
|
||||||
import Foundation
|
import Foundation
|
||||||
import SDWebImageSwiftUI
|
import SDWebImageSwiftUI
|
||||||
@ -486,15 +485,6 @@ struct VideoDetails: View {
|
|||||||
.padding(.horizontal)
|
.padding(.horizontal)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onReceive(
|
|
||||||
NotificationCenter.default
|
|
||||||
.publisher(for: .getTimeUpdatesNotification)
|
|
||||||
.receive(on: DispatchQueue.main)
|
|
||||||
) { notification in
|
|
||||||
if let cmTime = notification.object as? CMTime {
|
|
||||||
player.updateTime(cmTime)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user