You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
gui/src/app.rs

73 lines
2.6 KiB

use eframe::egui;
use crate::player::Player;
pub struct App {
pub player: Player,
pub tor_started: bool,
pub to_data: String
}
impl Default for App {
fn default() -> Self {
Self {
tor_started: false,
to_data: "".to_owned(),
player: Player::default()
}
}
}
impl eframe::App for App {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
ui.heading("lza gui");
ui.label("Made by ya boi, lza_menace");
ui.hyperlink("https://lzahq.tech");
ui.separator();
ui.label(format!("Now Playing: "));
ui.horizontal(|ui| {
if ui.button("▶").clicked() {
// If stream thread is done, start again
if self.player.stream_thread.is_finished() {
self.player.stream_thread = self.player.start_radio_stream();
}
if self.player.sink.len() != 1 {
let source: rodio::Decoder<std::io::BufReader<std::fs::File>> = self.player.get_radio_source();
let _ = &self.player.sink.append(source);
}
let _ = &self.player.sink.play();
}
if ui.button("■").clicked() {
let _ = &self.player.sink.pause();
}
});
ui.add(egui::Slider::new(&mut self.player.volume, 0.0..=100.0).text("Volume"));
self.player.sink.set_volume(self.player.volume / 100.0);
ui.label(format!("{:?}", self.player.get_song_meta()));
// ui.separator();
// ui.heading("Tor");
// if self.tor_started {
// ui.label("Tor started.");
// if ui.button("Clear Tor logs").clicked() {
// let _r: std::io::Result<()> = clear_tor_log();
// }
// ui.collapsing("View Tor logs:", |ui| {
// egui::ScrollArea::vertical().stick_to_bottom(true).show(ui, |ui| {
// let contents = std::fs::read_to_string(TOR_LOG.to_string()).unwrap();
// ui.label(contents);
// });
// });
// } else {
// if ui.button("Start Tor").clicked() {
// let _t: std::thread::JoinHandle<Result<u8, libtorError>> = start_tor();
// self.tor_started = true;
// }
// }
});
}
}