initial api impl
This commit is contained in:
@@ -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]
|
||||
|
||||
Reference in New Issue
Block a user