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.
80 lines
2.9 KiB
80 lines
2.9 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.horizontal(|ui| {
|
|
if ui.button("▶").clicked() {
|
|
// If stream thread is done, start again
|
|
if self.player.stream_thread.is_finished() {
|
|
ui.label("Starting stream...");
|
|
std::thread::sleep(std::time::Duration::from_secs(3));
|
|
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();
|
|
}
|
|
|
|
if ui.button("status").clicked() {
|
|
println!(
|
|
"is_paused: {}. empty: {}. len: {}. volume: {}.",
|
|
&self.player.sink.is_paused(),
|
|
&self.player.sink.empty(),
|
|
&self.player.sink.len(),
|
|
&self.player.sink.volume()
|
|
)
|
|
}
|
|
});
|
|
|
|
// 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;
|
|
// }
|
|
// }
|
|
});
|
|
}
|
|
} |