Skip to content

Commit

Permalink
Return f64 from Media::duration instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Lonami committed Feb 23, 2024
1 parent fd0ba9f commit ff70599
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions lib/grammers-client/src/types/media.rs
Original file line number Diff line number Diff line change
Expand Up @@ -319,15 +319,13 @@ impl Document {
}

/// Duration of video/audio, in seconds
pub fn duration(&self) -> Option<i32> {
pub fn duration(&self) -> Option<f64> {
match self.document.document.as_ref() {
Some(tl::enums::Document::Document(d)) => {
for attr in &d.attributes {
match attr {
tl::enums::DocumentAttribute::Video(v) => {
return Some(v.duration.min(i32::MAX as _) as i32)
}
tl::enums::DocumentAttribute::Audio(a) => return Some(a.duration),
tl::enums::DocumentAttribute::Video(v) => return Some(v.duration),
tl::enums::DocumentAttribute::Audio(a) => return Some(a.duration as _),
_ => {}
}
}
Expand Down

0 comments on commit ff70599

Please sign in to comment.