54 lines
1.4 KiB
Rust
54 lines
1.4 KiB
Rust
|
use gio::prelude::*;
|
||
|
use gtk::prelude::*;
|
||
|
use gtk::Orientation;
|
||
|
use rodio::Source;
|
||
|
use std::env::args;
|
||
|
use std::fs::File;
|
||
|
use std::io::BufReader;
|
||
|
|
||
|
const SPACING: i32 = 16;
|
||
|
|
||
|
fn build_ui(application: >k::Application) {
|
||
|
let window = gtk::ApplicationWindow::new(application);
|
||
|
|
||
|
window.set_title("lull");
|
||
|
window.set_border_width(SPACING as u32);
|
||
|
window.set_position(gtk::WindowPosition::Center);
|
||
|
window.set_default_size(400, 100);
|
||
|
|
||
|
let vertical = gtk::Box::new(Orientation::Vertical, SPACING);
|
||
|
window.add(&vertical);
|
||
|
|
||
|
// todo create user dir if it does not exist
|
||
|
|
||
|
// todo open user dir in file browser if it is empty
|
||
|
|
||
|
// todo iterate over audio files in user dir
|
||
|
// todo create row for each audio file
|
||
|
|
||
|
window.show_all();
|
||
|
|
||
|
let device = rodio::default_output_device().unwrap();
|
||
|
|
||
|
let file = File::open("/home/max/being-harsh.mp3")
|
||
|
.expect("Couldn't open audio file");
|
||
|
|
||
|
let source = rodio::Decoder::new(BufReader::new(file))
|
||
|
.expect("Couldn't decode audio");
|
||
|
|
||
|
rodio::play_raw(&device, source.convert_samples());
|
||
|
}
|
||
|
|
||
|
fn main() {
|
||
|
let application = gtk::Application::new(
|
||
|
Some("dev.tinybird.max.lull"),
|
||
|
Default::default()
|
||
|
).expect("Initialization failed...");
|
||
|
|
||
|
application.connect_activate(|app| {
|
||
|
build_ui(app);
|
||
|
});
|
||
|
|
||
|
application.run(&args().collect::<Vec<_>>());
|
||
|
}
|