mirror of
https://github.com/Dangoware/dmp-core.git
synced 2025-04-19 13:22:54 -05:00
moved queue to its own file
This commit is contained in:
parent
74e2933de1
commit
0e6a676e09
3 changed files with 27 additions and 23 deletions
|
@ -13,6 +13,7 @@ pub mod music_storage {
|
||||||
pub mod music_controller{
|
pub mod music_controller{
|
||||||
pub mod controller;
|
pub mod controller;
|
||||||
pub mod connections;
|
pub mod connections;
|
||||||
|
pub mod queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub mod music_player;
|
pub mod music_player;
|
||||||
|
|
|
@ -24,31 +24,9 @@ use crate::{
|
||||||
music_player::Player,
|
music_player::Player,
|
||||||
music_storage::library::{MusicLibrary, Song},
|
music_storage::library::{MusicLibrary, Song},
|
||||||
config::config::Config,
|
config::config::Config,
|
||||||
|
music_controller::queue::Queue,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct Queue {
|
|
||||||
player: Player,
|
|
||||||
name: String,
|
|
||||||
songs: Vec<Song>,
|
|
||||||
}
|
|
||||||
impl Queue {
|
|
||||||
fn new() -> Result<Self, Box<dyn Error>> {
|
|
||||||
Ok(
|
|
||||||
Queue {
|
|
||||||
player: Player::new()?,
|
|
||||||
name: String::new(),
|
|
||||||
songs: Vec::new()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn set_tracks(&mut self, tracks: Vec<Song>) {
|
|
||||||
let mut tracks = tracks;
|
|
||||||
self.songs.clear();
|
|
||||||
self.songs.append(&mut tracks);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Controller {
|
pub struct Controller {
|
||||||
// queues: Vec<Queue>,
|
// queues: Vec<Queue>,
|
||||||
config: Arc<RwLock<Config>>,
|
config: Arc<RwLock<Config>>,
|
||||||
|
|
25
src/music_controller/queue.rs
Normal file
25
src/music_controller/queue.rs
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
use crate::{music_player::Player, music_storage::library::Song};
|
||||||
|
use std::error::Error;
|
||||||
|
|
||||||
|
pub struct Queue {
|
||||||
|
pub player: Player,
|
||||||
|
pub name: String,
|
||||||
|
pub songs: Vec<Song>,
|
||||||
|
}
|
||||||
|
impl Queue {
|
||||||
|
pub fn new() -> Result<Self, Box<dyn Error>> {
|
||||||
|
Ok(
|
||||||
|
Queue {
|
||||||
|
player: Player::new()?,
|
||||||
|
name: String::new(),
|
||||||
|
songs: Vec::new()
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_tracks(&mut self, tracks: Vec<Song>) {
|
||||||
|
let mut tracks = tracks;
|
||||||
|
self.songs.clear();
|
||||||
|
self.songs.append(&mut tracks);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue