moved project to clip
This commit is contained in:
parent
a076b82cc4
commit
9a731177ca
4 changed files with 1905 additions and 392 deletions
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