Add buffering and cache length to stats

This commit is contained in:
Arkadiusz Fal
2022-06-17 13:43:11 +02:00
parent c35015e73f
commit b88adca781
3 changed files with 19 additions and 1 deletions

View File

@@ -80,6 +80,14 @@ final class MPVBackend: PlayerBackend {
client?.hwDecoder ?? "unknown"
}
var bufferingState: Double {
client?.bufferingState ?? 0
}
var cacheDuration: Double {
client?.cacheDuration ?? 0
}
init(model: PlayerModel, controls: PlayerControlsModel? = nil) {
self.model = model
self.controls = controls

View File

@@ -155,6 +155,14 @@ final class MPVClient: ObservableObject {
mpv.isNil ? "unknown" : (getString("hwdec-current") ?? "unknown")
}
var bufferingState: Double {
mpv.isNil ? 0.0 : getDouble("cache-buffering-state")
}
var cacheDuration: Double {
mpv.isNil ? 0.0 : getDouble("demuxer-cache-duration")
}
var duration: CMTime {
CMTime.secondsInDefaultTimescale(mpv.isNil ? -1 : getDouble("duration"))
}