feat: shuffle the whole library from the Random section
Shuffle all, the first tile of the Random section, plays random tracks from getRandomSongs and fetches another batch when fewer than five are left. Played tracks past the last fifty are dropped, so the queue stays small. Tracks queued meanwhile play after the playing track and after anything queued before them, ahead of the random ones. Playing anything else ends it, and it carries on after a restart.
This commit is contained in:
+8
-2
@@ -12,7 +12,7 @@ use anyhow::Result;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use crate::config;
|
||||
use crate::shuffle::Mode;
|
||||
use crate::shuffle::{Library, Mode};
|
||||
use crate::subsonic::{Client, Song};
|
||||
|
||||
const VERSION: u32 = 1;
|
||||
@@ -27,6 +27,8 @@ pub struct SavedQueue {
|
||||
pub order: Vec<usize>,
|
||||
#[serde(default)]
|
||||
pub shuffle: Mode,
|
||||
#[serde(default)]
|
||||
pub library: Option<Library>,
|
||||
pub current: Option<usize>,
|
||||
/// Seconds into the current song.
|
||||
pub position: f64,
|
||||
@@ -131,6 +133,7 @@ mod tests {
|
||||
songs: vec![song("1"), song("2")],
|
||||
order: vec![1, 0],
|
||||
shuffle: Mode::Tracks,
|
||||
library: Some(Library { added_end: 1 }),
|
||||
current: Some(1),
|
||||
position: 93.5,
|
||||
};
|
||||
@@ -162,7 +165,10 @@ mod tests {
|
||||
"songs": [{"id": "1", "title": "One"}], "current": 0, "position": 12.0}}}"#;
|
||||
fs::write(&path, text).unwrap();
|
||||
let q = load(&path).get(&client).cloned().expect("the queue");
|
||||
assert_eq!((q.songs.len(), q.order, q.shuffle), (1, vec![], Mode::Off));
|
||||
assert_eq!(
|
||||
(q.songs.len(), q.order, q.shuffle, q.library),
|
||||
(1, vec![], Mode::Off, None)
|
||||
);
|
||||
assert_eq!(q.songs[0].album_id, None);
|
||||
let _ = fs::remove_dir_all(path.parent().unwrap());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user