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"
|
||||
|
||||
[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
|
||||
gcc12
|
||||
rustc
|
||||
alsa-lib
|
||||
];
|
||||
|
||||
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 gtk::{glib, Application, ApplicationWindow};
|
||||
use clap::Parser;
|
||||
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 {
|
||||
// Create a new application
|
||||
let app = Application::builder().application_id(APP_ID).build();
|
||||
|
||||
// Connect to "activate" signal of `app`
|
||||
app.connect_activate(build_ui);
|
||||
|
||||
// Run the application
|
||||
app.run()
|
||||
/// Name of the visualizer used.
|
||||
#[arg(short, long)]
|
||||
visualizer: String,
|
||||
}
|
||||
|
||||
fn build_ui(app: &Application) {
|
||||
// Create a window and set the title
|
||||
fn main() {
|
||||
let args = Args::parse();
|
||||
|
||||
let button = Button::builder
|
||||
let filename = args.file.as_str();
|
||||
|
||||
let window = ApplicationWindow::builder()
|
||||
.application(app)
|
||||
.title("My GTK App")
|
||||
.build();
|
||||
let (_stream, stream_handle) = OutputStream::try_default().unwrap();
|
||||
let sink = Sink::try_new(&stream_handle).unwrap();
|
||||
|
||||
// Present window
|
||||
window.present();
|
||||
let file = BufReader::new(File::open(filename).expect("Error while opening provided file."));
|
||||
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