moved project to clip
This commit is contained in:
parent
a076b82cc4
commit
9a731177ca
4 changed files with 1905 additions and 392 deletions
2244
Cargo.lock
generated
2244
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
|
@ -4,4 +4,6 @@ version = "0.1.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
gtk = { version = "0.9.6", package = "gtk4", features = ["v4_16"] }
|
clap = { version = "4.5.32", features = ["derive"] }
|
||||||
|
rodio = "0.20.1"
|
||||||
|
winit = "0.30.9"
|
||||||
|
|
|
@ -71,6 +71,7 @@
|
||||||
gtk4
|
gtk4
|
||||||
gcc12
|
gcc12
|
||||||
rustc
|
rustc
|
||||||
|
alsa-lib
|
||||||
];
|
];
|
||||||
|
|
||||||
env = {
|
env = {
|
||||||
|
@ -80,5 +81,7 @@
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
packages."x86_64-linux".default = { };
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
46
src/main.rs
46
src/main.rs
|
@ -1,29 +1,33 @@
|
||||||
use gtk::prelude::*;
|
use clap::Parser;
|
||||||
use gtk::{glib, Application, ApplicationWindow};
|
use rodio::{Decoder, OutputStream, Sink};
|
||||||
|
use std::fs::File;
|
||||||
|
use std::io::BufReader;
|
||||||
|
|
||||||
const APP_ID: &str = "org.gtk_rs.HelloWorld2";
|
/// a nice music visualizer
|
||||||
|
#[derive(Parser, Debug)]
|
||||||
|
#[command(version, about, long_about = None)]
|
||||||
|
struct Args {
|
||||||
|
/// Name of the file you wanna visualise
|
||||||
|
#[arg(short, long, value_name = "FILE")]
|
||||||
|
file: String,
|
||||||
|
|
||||||
fn main() -> glib::ExitCode {
|
/// Name of the visualizer used.
|
||||||
// Create a new application
|
#[arg(short, long)]
|
||||||
let app = Application::builder().application_id(APP_ID).build();
|
visualizer: String,
|
||||||
|
|
||||||
// Connect to "activate" signal of `app`
|
|
||||||
app.connect_activate(build_ui);
|
|
||||||
|
|
||||||
// Run the application
|
|
||||||
app.run()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_ui(app: &Application) {
|
fn main() {
|
||||||
// Create a window and set the title
|
let args = Args::parse();
|
||||||
|
|
||||||
let button = Button::builder
|
let filename = args.file.as_str();
|
||||||
|
|
||||||
let window = ApplicationWindow::builder()
|
let (_stream, stream_handle) = OutputStream::try_default().unwrap();
|
||||||
.application(app)
|
let sink = Sink::try_new(&stream_handle).unwrap();
|
||||||
.title("My GTK App")
|
|
||||||
.build();
|
|
||||||
|
|
||||||
// Present window
|
let file = BufReader::new(File::open(filename).expect("Error while opening provided file."));
|
||||||
window.present();
|
let source = Decoder::new(file).unwrap();
|
||||||
|
|
||||||
|
sink.append(source);
|
||||||
|
println!("playing file!! Ctrl-c to stop");
|
||||||
|
sink.sleep_until_end();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue