|
|
|
@ -1,22 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
use std::time::{Duration, Instant};
|
|
|
|
|
|
|
|
use eframe::egui;
|
|
|
|
use eframe::egui;
|
|
|
|
|
|
|
|
use std::time::{Duration, Instant};
|
|
|
|
|
|
|
|
|
|
|
|
mod player_interface;
|
|
|
|
mod player_interface;
|
|
|
|
|
|
|
|
|
|
|
|
use player_interface::SongMetadata;
|
|
|
|
use player_interface::SongMetadata;
|
|
|
|
|
|
|
|
|
|
|
|
fn main() -> Result<(), eframe::Error>
|
|
|
|
fn main() -> Result<(), eframe::Error>
|
|
|
|
{
|
|
|
|
{
|
|
|
|
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
|
|
|
|
env_logger::init(); // Log to stderr (if you run with `RUST_LOG=debug`).
|
|
|
|
let options = eframe::NativeOptions {
|
|
|
|
let options = eframe::NativeOptions
|
|
|
|
|
|
|
|
{
|
|
|
|
viewport: egui::ViewportBuilder::default().with_inner_size([600.0, 240.0]),
|
|
|
|
viewport: egui::ViewportBuilder::default().with_inner_size([600.0, 240.0]),
|
|
|
|
..Default::default()
|
|
|
|
..Default::default()
|
|
|
|
};
|
|
|
|
};
|
|
|
|
eframe::run_native(
|
|
|
|
eframe::run_native(
|
|
|
|
"Media Metadata Viewer",
|
|
|
|
"Media Metadata Viewer",
|
|
|
|
options,
|
|
|
|
options,
|
|
|
|
Box::new(|cc| {
|
|
|
|
Box::new(|cc|
|
|
|
|
|
|
|
|
{
|
|
|
|
// This gives us image support:
|
|
|
|
// This gives us image support:
|
|
|
|
egui_extras::install_image_loaders(&cc.egui_ctx);
|
|
|
|
egui_extras::install_image_loaders(&cc.egui_ctx);
|
|
|
|
|
|
|
|
|
|
|
|
@ -29,53 +29,55 @@ struct JpmmvApp
|
|
|
|
{
|
|
|
|
{
|
|
|
|
last_query_time: Instant,
|
|
|
|
last_query_time: Instant,
|
|
|
|
current_metadata: SongMetadata,
|
|
|
|
current_metadata: SongMetadata,
|
|
|
|
|
|
|
|
force_query: bool,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl Default for JpmmvApp
|
|
|
|
impl Default for JpmmvApp
|
|
|
|
{
|
|
|
|
{
|
|
|
|
fn default() -> Self
|
|
|
|
fn default() -> Self {
|
|
|
|
{
|
|
|
|
|
|
|
|
Self {
|
|
|
|
Self {
|
|
|
|
last_query_time: Instant::now(),
|
|
|
|
last_query_time: Instant::now(),
|
|
|
|
current_metadata: SongMetadata::new(),
|
|
|
|
current_metadata: SongMetadata::new(),
|
|
|
|
|
|
|
|
force_query: true,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
impl eframe::App for JpmmvApp
|
|
|
|
impl eframe::App for JpmmvApp
|
|
|
|
{
|
|
|
|
{
|
|
|
|
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame)
|
|
|
|
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if self.last_query_time.elapsed() >= Duration::from_secs(1)
|
|
|
|
if self.last_query_time.elapsed() >= Duration::from_secs(1) || self.force_query
|
|
|
|
{
|
|
|
|
{
|
|
|
|
self.current_metadata = player_interface::get_song_metadata();
|
|
|
|
self.current_metadata = player_interface::get_song_metadata();
|
|
|
|
self.last_query_time = Instant::now();
|
|
|
|
self.last_query_time = Instant::now();
|
|
|
|
|
|
|
|
self.force_query = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
egui::CentralPanel::default().show(ctx, |ui|
|
|
|
|
egui::CentralPanel::default().show(ctx, |ui|
|
|
|
|
{
|
|
|
|
|
|
|
|
ui.heading("Media Meta Viewer");
|
|
|
|
|
|
|
|
ui.horizontal_centered(|ui|
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ui.image(egui::include_image!(
|
|
|
|
// ui.heading("Media Meta Viewer");
|
|
|
|
"../assets/Music Note.png"
|
|
|
|
ui.horizontal_centered(|ui|
|
|
|
|
));
|
|
|
|
{
|
|
|
|
|
|
|
|
ui.image(egui::include_image!("../assets/Music Note.png"));
|
|
|
|
|
|
|
|
|
|
|
|
ui.vertical(|ui|{
|
|
|
|
ui.vertical(|ui| {
|
|
|
|
ui.label(format!("{}", self.current_metadata.name));
|
|
|
|
ui.label(format!("{}", self.current_metadata.name));
|
|
|
|
ui.label(format!("by: {}", self.current_metadata.artist));
|
|
|
|
ui.label(format!("by: {}", self.current_metadata.artist));
|
|
|
|
ui.label(format!("album: {}", self.current_metadata.album));
|
|
|
|
ui.label(format!("album: {}", self.current_metadata.album));
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
ui.style_mut().text_styles.insert(
|
|
|
|
|
|
|
|
egui::TextStyle::Button,
|
|
|
|
|
|
|
|
egui::FontId::new(24.0, eframe::epaint::FontFamily::Proportional),
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
if ui.button("Skip").clicked()
|
|
|
|
if ui.button("Skip").clicked()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
player_interface::next_track();
|
|
|
|
player_interface::next_track();
|
|
|
|
}
|
|
|
|
self.force_query = true
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|