basic
This commit is contained in:
commit
44902c452c
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/target
|
1092
Cargo.lock
generated
Normal file
1092
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
7
Cargo.toml
Normal file
7
Cargo.toml
Normal 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
45
src/main.rs
Normal 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>;
|
||||||
|
}
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user