initial api impl

This commit is contained in:
2024-10-12 12:15:31 -06:00
parent 666d8b8766
commit 10a13d3daa
12 changed files with 471 additions and 17 deletions
+14 -1
View File
@@ -42,6 +42,9 @@ pub enum SessionCommand {
ShutdownPlayer,
Disconnect,
DisconnectTimedOut,
QueuePlaylist {
playlist_uri: String,
},
}
pub struct Session {
@@ -236,7 +239,6 @@ impl Session {
SessionCommand::GetOwner(sender) => _ = sender.send(self.owner),
SessionCommand::GetPlayer(sender) => _ = sender.send(self.player.clone()),
SessionCommand::GetActive(sender) => _ = sender.send(self.active),
SessionCommand::CreatePlaybackEmbed(handle, interaction, behavior) => {
match PlaybackEmbed::create(self, handle, interaction, behavior).await {
Ok(opt_handle) => {
@@ -290,6 +292,9 @@ impl Session {
return ControlFlow::Break(());
}
SessionCommand::QueuePlaylist { playlist_uri } => {
self.player.queue_playlist(playlist_uri).await;
}
};
ControlFlow::Continue(())
@@ -551,6 +556,14 @@ impl SessionHandle {
error!("Failed to send command: {why}");
}
}
pub async fn queue_playlist(&self, playlist_uri: String) -> Result<()> {
self.commands
.send(SessionCommand::QueuePlaylist { playlist_uri })
.await?;
Ok(())
}
}
#[async_trait]