mirror of
https://github.com/Dangoware/dango-music-player.git
synced 2025-05-04 00:32:55 -05:00
Hacky fix for crashing when advancing the queue rapidly
This commit is contained in:
parent
6b3ac348ac
commit
54cdea797e
3 changed files with 12 additions and 9 deletions
|
@ -359,7 +359,7 @@ impl Controller {
|
|||
lib_mail.send(LibraryCommand::AllSongs).await.unwrap();
|
||||
|
||||
let LibraryResponse::AllSongs(songs) = lib_mail.recv().await.unwrap() else {
|
||||
unreachable!()
|
||||
continue;
|
||||
};
|
||||
lib_mail.send(LibraryCommand::Song(np_song.song.uuid)).await.unwrap();
|
||||
let LibraryResponse::Song(_, i) = lib_mail.recv().await.unwrap() else {
|
||||
|
|
|
@ -92,20 +92,23 @@ pub fn run() {
|
|||
.unwrap()
|
||||
.to_string();
|
||||
|
||||
let bytes = if query.as_str() == "default" { DEFAULT_IMAGE.to_vec() }
|
||||
else {
|
||||
futures::executor::block_on(async move {
|
||||
let bytes = if query.as_str() == "default" {
|
||||
Some(DEFAULT_IMAGE.to_vec())
|
||||
} else {futures::executor::block_on(async move {
|
||||
let controller = ctx.app_handle().state::<ControllerHandle>();
|
||||
controller.lib_mail.send(dmp_core::music_controller::controller::LibraryCommand::Song(Uuid::parse_str(query.as_str()).unwrap())).await.unwrap();
|
||||
let LibraryResponse::Song(song, _) = controller.lib_mail.recv().await.unwrap() else { unreachable!() };
|
||||
song.album_art(0).unwrap_or_else(|_| None).unwrap_or(DEFAULT_IMAGE.to_vec())
|
||||
let LibraryResponse::Song(song, _) = controller.lib_mail.recv().await.unwrap() else {
|
||||
return None
|
||||
};
|
||||
Some(song.album_art(0).unwrap_or_else(|_| None).unwrap_or(DEFAULT_IMAGE.to_vec()))
|
||||
})};
|
||||
|
||||
res.respond(
|
||||
Response::builder()
|
||||
.header("Origin", "*")
|
||||
.header("Content-Length", bytes.len())
|
||||
.header("Content-Length", bytes.as_ref().unwrap_or(&vec![]).len())
|
||||
.status(200)
|
||||
.body(bytes)
|
||||
.body(bytes.unwrap_or_default())
|
||||
.unwrap()
|
||||
);
|
||||
})
|
||||
|
|
|
@ -55,7 +55,7 @@ pub async fn get_volume(ctrl_handle: State<'_, ControllerHandle>) -> Result<(),
|
|||
pub async fn next(app: AppHandle<Wry>, ctrl_handle: State<'_, ControllerHandle>) -> Result<(), String> {
|
||||
ctrl_handle.player_mail.send(dmp_core::music_controller::controller::PlayerCommand::NextSong).await.unwrap();
|
||||
let PlayerResponse::NowPlaying(song) = ctrl_handle.player_mail.recv().await.unwrap() else {
|
||||
unreachable!()
|
||||
return Ok(())
|
||||
};
|
||||
println!("next");
|
||||
app.emit("now_playing_change", _Song::from(&song)).unwrap();
|
||||
|
|
Loading…
Reference in a new issue