Move progress length to TrackInfo
This commit is contained in:
parent
9eb2c1c431
commit
1fe366ce9f
|
@ -34,9 +34,6 @@ pub enum LoopStatus {
|
|||
pub struct ProgressChanged {
|
||||
/// Current position into the track in seconds.
|
||||
pub position: f32,
|
||||
|
||||
/// Length of the current track in seconds.
|
||||
pub length: Option<f32>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
|
@ -48,7 +45,7 @@ pub struct AlbumInfo {
|
|||
pub artists: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
|
||||
pub struct TrackInfo {
|
||||
/// The title of the current track.
|
||||
pub title: Option<String>,
|
||||
|
@ -58,6 +55,9 @@ pub struct TrackInfo {
|
|||
|
||||
/// The optional track number on the disc the album the track appears on.
|
||||
pub track_number: Option<i32>,
|
||||
|
||||
/// Length of the track in seconds.
|
||||
pub length: Option<f32>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
|
|
|
@ -40,6 +40,10 @@ impl<'a> From<MetadataMap<'a>> for Metadata {
|
|||
track_number: map
|
||||
.get("xesam:trackNumber")
|
||||
.and_then(|v| TryFrom::try_from(v).ok()),
|
||||
length: map
|
||||
.get("xesam:length")
|
||||
.and_then(|v| i64::try_from(v).ok())
|
||||
.map(|us| us as f32 / 1_000_000.0), // 1,000,000 microseconds in a second
|
||||
};
|
||||
|
||||
Self { album, track }
|
||||
|
|
Loading…
Reference in New Issue