Add work and recording editor

This commit is contained in:
Elias Projahn 2025-01-15 11:23:04 +01:00
parent 36b2f1097e
commit 364557d959
30 changed files with 3308 additions and 418 deletions

View file

@ -1,5 +1,6 @@
use std::{
cell::{Cell, OnceCell, RefCell},
path::PathBuf,
sync::Arc,
};
@ -236,7 +237,7 @@ impl MusicusPlayer {
}
pub fn play_recording(&self, recording: &Recording) {
let tracks = &recording.tracks;
let tracks = &self.library().unwrap().tracks_for_recording(&recording.recording_id).unwrap();
if tracks.is_empty() {
log::warn!("Ignoring recording without tracks being added to the playlist.");
@ -254,7 +255,7 @@ impl MusicusPlayer {
&recording.work.name.get(),
Some(&performances),
None,
&tracks[0].path,
&self.library_path_to_file_path(&tracks[0].path),
&tracks[0].track_id,
));
} else {
@ -282,7 +283,7 @@ impl MusicusPlayer {
&recording.work.name.get(),
Some(&performances),
Some(&track_title(&first_track, 1)),
&first_track.path,
&self.library_path_to_file_path(&first_track.path),
&first_track.track_id,
));
@ -294,7 +295,7 @@ impl MusicusPlayer {
Some(&performances),
// track number = track index + 1 (first track) + 1 (zero based)
Some(&track_title(&track, index + 2)),
&track.path,
&self.library_path_to_file_path(&track.path),
&track.track_id,
));
}
@ -384,6 +385,14 @@ impl MusicusPlayer {
self.play_recording(&recording);
}
}
fn library_path_to_file_path(&self, path: &str) -> String {
PathBuf::from(self.library().unwrap().folder())
.join(path)
.to_str()
.unwrap()
.to_owned()
}
}
impl Default for MusicusPlayer {