initial
This commit is contained in:
commit
3845a729a2
|
@ -0,0 +1,2 @@
|
|||
/target
|
||||
/Cargo.lock
|
|
@ -0,0 +1,11 @@
|
|||
[package]
|
||||
name = "lull"
|
||||
description = "a catalogue of soothing sounds"
|
||||
version = "0.1.0"
|
||||
authors = ["Max Bradbury <max@tinybird.info>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
gio = "^0"
|
||||
gtk = "^0"
|
||||
rodio = "^0.11.0"
|
|
@ -0,0 +1,53 @@
|
|||
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<_>>());
|
||||
}
|
Loading…
Reference in New Issue