This commit is contained in:
Justine 2024-08-11 13:41:13 +02:00
commit 44902c452c
4 changed files with 1145 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/target

1092
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

7
Cargo.toml Normal file
View File

@ -0,0 +1,7 @@
[package]
name = "sweetmusic"
version = "0.1.0"
edition = "2021"
[dependencies]
rodio = { version = "0.19.0", features = ["symphonia-all"] }

45
src/main.rs Normal file
View File

@ -0,0 +1,45 @@
use std::fs::File;
use std::io::BufReader;
use std::path::{Path, PathBuf};
use std::time::Duration;
use rodio::{Decoder, OutputStream, Sink, Source};
#[derive(Debug, Clone)]
struct SongMeta {
title: String,
artist: String,
album: String,
duration: Duration,
cover_path: Path,
path: Path,
}
impl SongMeta {
fn new(filepath: Path) -> Self;
}
#[derive(Debug, Clone)]
struct AudioPlayer {
sink: Sink,
playlist: Vec<SongMeta>,
}
#[derive(Debug, Clone)]
enum PlayerError {
IndexNotFound,
SomethingElse,
}
impl AudioPlayer {
fn new() -> Self;
fn from_playlist(playlist: Vec<SongMeta>) -> Self;
fn add_playlist(&mut self, playlist: Vec<SongMeta>);
fn skip_forward(&mut self);
fn skip_backwards(&mut self);
fn pause(&mut self);
fn play(&mut self);
fn set_vol(&mut self, vol: f32);
fn goto(&mut self; index: usize) -> Result<(), PlayerError>;
}