🏡 index : ~doyle/shalom.git

author Jordan Doyle <jordan@doyle.la> 2023-11-01 1:34:43.0 +00:00:00
committer Jordan Doyle <jordan@doyle.la> 2023-11-01 1:34:43.0 +00:00:00
commit
d539451f9e78044ad9400f11791b1451b3b199ff [patch]
tree
1e5ef046b050fbefc813fd38bc3743a612c30e81
parent
7000c41cba743674f237979415a5a5f98042b180
download
d539451f9e78044ad9400f11791b1451b3b199ff.tar.gz

Fix crashing when nothing is playing



Diff

 shalom/src/widgets/media_player.rs | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/shalom/src/widgets/media_player.rs b/shalom/src/widgets/media_player.rs
index c512fd9..b9af5aa 100644
--- a/shalom/src/widgets/media_player.rs
+++ b/shalom/src/widgets/media_player.rs
@@ -72,8 +72,16 @@ impl<M> Component<M, Renderer> for MediaPlayer<M> {
        container(
            row![
                container(crate::widgets::track_card::track_card(
                    self.device.media_artist.as_ref().unwrap().to_string(),
                    self.device.media_title.as_ref().unwrap().to_string(),
                    self.device
                        .media_artist
                        .as_ref()
                        .map(ToString::to_string)
                        .unwrap_or_default(),
                    self.device
                        .media_title
                        .as_ref()
                        .map(ToString::to_string)
                        .unwrap_or_default(),
                    self.image.clone(),
                ),)
                .width(Length::FillPortion(8)),
@@ -120,11 +128,11 @@ impl<M> Component<M, Renderer> for MediaPlayer<M> {
                            .style(Text::Color(SLATE_400))
                            .size(12),
                        slider(
                            0.0..=self.device.media_duration.unwrap().as_secs_f64(),
                            0.0..=self.device.media_duration.unwrap_or_default().as_secs_f64(),
                            state.track_position.as_secs_f64(),
                            Event::PositionChange
                        ),
                        text(format_time(self.device.media_duration.unwrap()))
                        text(format_time(self.device.media_duration.unwrap_or_default()))
                            .style(Text::Color(SLATE_400))
                            .size(12),
                    ]