pub struct ObservedTime {
position: f64,
duration: Option<f64>,
}Expand description
The last playback time actually observed while media was loaded.
Some backends expose position and duration as live properties of the
loaded file — MPV’s time-pos and duration stop resolving the moment it
unloads the file at EOF. Reading them straight through means that at exactly
the moment end-of-file handling wants to know where playback got to, the
answer is 0.0 / unknown: the player appears to rewind to 0:00 as it ends.
The polling thread records here, and the accessors fall back to it, so an EOF reads as the last timestamp rather than as zero.
Fields§
§position: f64§duration: Option<f64>Implementations§
Source§impl ObservedTime
impl ObservedTime
Sourcepub fn record(&mut self, position: f64, duration: f64)
pub fn record(&mut self, position: f64, duration: f64)
Record a live reading. Non-positive durations are treated as unknown — that is how a backend reports “not established yet”, not a real zero.
Sourcepub fn record_position(&mut self, position: f64)
pub fn record_position(&mut self, position: f64)
Record a position alone, e.g. straight after a seek, before the next poll.
Sourcepub fn reset(&mut self)
pub fn reset(&mut self)
Forget everything — a different file is loading, and the previous one’s timestamp must not leak into it.
Sourcepub fn position_or_last(&self, live: Option<f64>) -> f64
pub fn position_or_last(&self, live: Option<f64>) -> f64
The live reading if there is one, else the last observed value.
Sourcepub fn last_position(&self) -> f64
pub fn last_position(&self) -> f64
The last observed position, with no live reading to prefer — the case where the reporter is the only source there is (webview-rendered media, which the native backend cannot see at all).
Sourcepub fn last_duration(&self) -> Option<f64>
pub fn last_duration(&self) -> Option<f64>
The last observed duration, if one was ever established.
Trait Implementations§
Source§impl Clone for ObservedTime
impl Clone for ObservedTime
Source§fn clone(&self) -> ObservedTime
fn clone(&self) -> ObservedTime
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more