kithara_play/player/
view.rs1use crate::bridge::PlaybackSnapshot;
2
3#[derive(Clone, Copy, Debug, Default, PartialEq)]
8#[non_exhaustive]
9pub struct PlaybackView {
10 pub buffered: Option<f64>,
12 pub duration: Option<f64>,
14 pub position: Option<f64>,
16 pub playing: bool,
18}
19
20impl From<PlaybackSnapshot> for PlaybackView {
21 fn from(snapshot: PlaybackSnapshot) -> Self {
22 Self {
23 position: Some(snapshot.position()),
24 duration: (snapshot.duration() > 0.0).then_some(snapshot.duration()),
25 buffered: Some(snapshot.frontier().max(snapshot.cached())),
26 playing: snapshot.is_playing(),
27 }
28 }
29}