mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 19:57:25 +01:00
New search page
This commit is contained in:
parent
a6e0935df8
commit
cff489f43e
12 changed files with 830 additions and 793 deletions
|
|
@ -203,7 +203,7 @@ impl Player {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn play_recording(&self, recording: &Recording) {
|
||||
pub fn recording_to_playlist(&self, recording: &Recording) -> Vec<PlaylistItem> {
|
||||
let tracks = &self
|
||||
.library()
|
||||
.unwrap()
|
||||
|
|
@ -211,8 +211,8 @@ impl Player {
|
|||
.unwrap();
|
||||
|
||||
if tracks.is_empty() {
|
||||
log::warn!("Ignoring recording without tracks being added to the playlist.");
|
||||
return;
|
||||
log::warn!("Recording without tracks: {}.", &recording.recording_id);
|
||||
return Vec::new();
|
||||
}
|
||||
|
||||
let performances = recording.performers_string();
|
||||
|
|
@ -272,14 +272,14 @@ impl Player {
|
|||
}
|
||||
}
|
||||
|
||||
self.append(items);
|
||||
items
|
||||
}
|
||||
|
||||
pub fn append(&self, tracks: Vec<PlaylistItem>) {
|
||||
pub fn append(&self, items: Vec<PlaylistItem>) {
|
||||
let playlist = self.playlist();
|
||||
|
||||
for track in tracks {
|
||||
playlist.append(&track);
|
||||
for item in items {
|
||||
playlist.append(&item);
|
||||
}
|
||||
|
||||
if !self.active() && playlist.n_items() > 0 {
|
||||
|
|
@ -289,6 +289,21 @@ impl Player {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn append_and_play(&self, items: Vec<PlaylistItem>) {
|
||||
let playlist = self.playlist();
|
||||
let first_index = playlist.n_items();
|
||||
|
||||
for item in items {
|
||||
playlist.append(&item);
|
||||
}
|
||||
|
||||
if playlist.n_items() > first_index {
|
||||
self.set_active(true);
|
||||
self.set_current_index(first_index);
|
||||
self.play();
|
||||
}
|
||||
}
|
||||
|
||||
pub fn play_pause(&self) {
|
||||
if self.playing() {
|
||||
self.pause();
|
||||
|
|
@ -423,7 +438,8 @@ impl Player {
|
|||
if let Some(library) = self.library() {
|
||||
// TODO: if program.play_full_recordings() {
|
||||
let recording = library.generate_recording(program).unwrap();
|
||||
self.play_recording(&recording);
|
||||
let playlist = self.recording_to_playlist(&recording);
|
||||
self.append(playlist);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue