epileptic/src/main.rs
2025-03-16 21:54:13 +01:00

33 lines
873 B
Rust

use clap::Parser;
use rodio::{Decoder, OutputStream, Sink};
use std::fs::File;
use std::io::BufReader;
/// 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,
/// Name of the visualizer used.
#[arg(short, long)]
visualizer: String,
}
fn main() {
let args = Args::parse();
let filename = args.file.as_str();
let (_stream, stream_handle) = OutputStream::try_default().unwrap();
let sink = Sink::try_new(&stream_handle).unwrap();
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();
}