Fix album-art-data fetching, bump version 0.2.4

This commit is contained in:
Stephen Seo 2021-12-18 15:52:50 +09:00
parent 0ffc98ec18
commit d13a8a7b88
5 changed files with 13 additions and 3 deletions

2
Cargo.lock generated
View file

@ -1427,7 +1427,7 @@ dependencies = [
[[package]]
name = "mpd_info_screen"
version = "0.2.3"
version = "0.2.4"
dependencies = [
"ggez",
"image",

View file

@ -1,6 +1,6 @@
[package]
name = "mpd_info_screen"
version = "0.2.3"
version = "0.2.4"
edition = "2018"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -9,7 +9,7 @@ counter, and the filename currently being played
# Usage
mpd_info_screen 0.2.3
mpd_info_screen 0.2.4
USAGE:
mpd_info_screen [FLAGS] [OPTIONS] <host> [port]

View file

@ -186,6 +186,12 @@ impl MPDDisplay {
.try_read()
.map_err(|_| String::from("ERROR get_image_from_data: Failed to get read_handle"))?;
if !read_handle.is_art_data_ready() {
return Err(String::from(
"ERROR get_image_from_data: art data not ready",
));
}
let mut image_format: image::ImageFormat = image::ImageFormat::Png;
match read_handle.get_art_type().as_str() {
"image/png" => image_format = image::ImageFormat::Png,

View file

@ -318,6 +318,10 @@ impl MPDHandler {
self.art_data_type.clone()
}
pub fn is_art_data_ready(&self) -> bool {
self.art_data.len() == self.art_data_size
}
pub fn get_art_data(&self) -> &[u8] {
&self.art_data
}