mirror of
https://github.com/Dangoware/dango-music-player.git
synced 2025-06-22 22:52:59 -05:00
changed queue to use move_to instead of play_now when selecting a song from the queue
This commit is contained in:
parent
99bf0b6855
commit
407b53e941
7 changed files with 37 additions and 22 deletions
|
@ -109,10 +109,7 @@ pub enum LibraryCommand {
|
||||||
AllSongs,
|
AllSongs,
|
||||||
GetLibrary,
|
GetLibrary,
|
||||||
ExternalPlaylist(Uuid),
|
ExternalPlaylist(Uuid),
|
||||||
PlaylistSong{
|
PlaylistSong { list_uuid: Uuid, item_uuid: Uuid },
|
||||||
list_uuid: Uuid,
|
|
||||||
item_uuid: Uuid
|
|
||||||
},
|
|
||||||
Playlist(Uuid),
|
Playlist(Uuid),
|
||||||
ImportM3UPlayList(PathBuf),
|
ImportM3UPlayList(PathBuf),
|
||||||
Save,
|
Save,
|
||||||
|
@ -142,6 +139,7 @@ pub enum QueueCommand {
|
||||||
Get,
|
Get,
|
||||||
Clear,
|
Clear,
|
||||||
Remove(usize),
|
Remove(usize),
|
||||||
|
MoveTo(usize),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Clone)]
|
#[derive(Debug, PartialEq, Clone)]
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
use std::path::PathBuf;
|
use std::path::PathBuf;
|
||||||
|
|
||||||
use async_channel::{Receiver, Sender};
|
use async_channel::{Receiver, Sender};
|
||||||
|
use rcue::cue::Command;
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::music_storage::{
|
use crate::music_storage::{
|
||||||
|
@ -108,6 +109,15 @@ impl ControllerHandle {
|
||||||
queue
|
queue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn queue_move_to(&self, index: usize) -> Result<(), QueueError> {
|
||||||
|
let (command, tx) = QueueCommandInput::command(QueueCommand::MoveTo(index));
|
||||||
|
self.queue_mail_rx.send(command).await.unwrap();
|
||||||
|
let QueueResponse::Empty(res) = tx.recv().await.unwrap() else {
|
||||||
|
unreachable!()
|
||||||
|
};
|
||||||
|
res
|
||||||
|
}
|
||||||
|
|
||||||
// The Player Section
|
// The Player Section
|
||||||
pub async fn play_now(&self, uuid: Uuid, location: PlayerLocation) -> Result<Song, QueueError> {
|
pub async fn play_now(&self, uuid: Uuid, location: PlayerLocation) -> Result<Song, QueueError> {
|
||||||
let (command, tx) = PlayerCommandInput::command(PlayerCommand::PlayNow(uuid, location));
|
let (command, tx) = PlayerCommandInput::command(PlayerCommand::PlayNow(uuid, location));
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
use rayon::iter::IndexedParallelIterator;
|
||||||
|
|
||||||
use crate::music_storage::queue::{Queue, QueueError, QueueItemType};
|
use crate::music_storage::queue::{Queue, QueueError, QueueItemType};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
@ -69,6 +71,12 @@ impl Controller {
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
QueueCommand::MoveTo(index) => {
|
||||||
|
res_rx
|
||||||
|
.send(QueueResponse::Empty(queue.move_to(index)))
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ use wrappers::{_Song, stop};
|
||||||
|
|
||||||
use crate::wrappers::{
|
use crate::wrappers::{
|
||||||
get_library, get_playlist, get_playlists, get_queue, get_song, import_playlist, next, pause,
|
get_library, get_playlist, get_playlists, get_queue, get_song, import_playlist, next, pause,
|
||||||
play, prev, remove_from_queue, seek, set_volume,
|
play, prev, queue_move_to, remove_from_queue, seek, set_volume,
|
||||||
};
|
};
|
||||||
use commands::{add_song_to_queue, display_album_art, last_fm_init_auth, play_now};
|
use commands::{add_song_to_queue, display_album_art, last_fm_init_auth, play_now};
|
||||||
|
|
||||||
|
@ -69,6 +69,7 @@ pub fn run() {
|
||||||
save_config,
|
save_config,
|
||||||
close_window,
|
close_window,
|
||||||
start_controller,
|
start_controller,
|
||||||
|
queue_move_to,
|
||||||
// test_menu,
|
// test_menu,
|
||||||
])
|
])
|
||||||
.manage(tempfile::TempDir::new().unwrap())
|
.manage(tempfile::TempDir::new().unwrap())
|
||||||
|
|
|
@ -272,3 +272,14 @@ pub async fn get_song(
|
||||||
pub async fn seek(ctrl_handle: State<'_, ControllerHandle>, time: i64) -> Result<(), String> {
|
pub async fn seek(ctrl_handle: State<'_, ControllerHandle>, time: i64) -> Result<(), String> {
|
||||||
ctrl_handle.seek(time).await.map_err(|e| e.to_string())
|
ctrl_handle.seek(time).await.map_err(|e| e.to_string())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[tauri::command]
|
||||||
|
pub async fn queue_move_to(
|
||||||
|
ctrl_handle: State<'_, ControllerHandle>,
|
||||||
|
index: usize,
|
||||||
|
) -> Result<(), String> {
|
||||||
|
ctrl_handle
|
||||||
|
.queue_move_to(index)
|
||||||
|
.await
|
||||||
|
.map_err(|e| e.to_string())
|
||||||
|
}
|
||||||
|
|
15
src/App.tsx
15
src/App.tsx
|
@ -277,19 +277,6 @@ function Song(props: SongProps) {
|
||||||
menu.popup(pos);
|
menu.popup(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
// useEffect(() => {
|
|
||||||
// const unlistenPromise = listen<string>("add_song_to_queue", (event) => {
|
|
||||||
// switch (event.payload) {
|
|
||||||
// default:
|
|
||||||
// console.log("Unimplemented application menu id:", event.payload);
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
// return () => {
|
|
||||||
// unlistenPromise.then((unlisten) => unlisten());
|
|
||||||
// };
|
|
||||||
// }, []);
|
|
||||||
|
|
||||||
return(
|
return(
|
||||||
<div
|
<div
|
||||||
onDoubleClick={() => {
|
onDoubleClick={() => {
|
||||||
|
@ -424,7 +411,7 @@ function QueueSong({ song, location, index }: QueueSongProps) {
|
||||||
}
|
}
|
||||||
|
|
||||||
let playNow = () => {
|
let playNow = () => {
|
||||||
invoke('play_now', { uuid: song.uuid, location: location }).then(() => {})
|
invoke('queue_move_to', { index: index }).then(() => {})
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
Loading…
Reference in a new issue