mirror of
https://github.com/librespot-org/librespot.git
synced 2025-01-17 17:34:04 +00:00
Allow player session changes
This commit is contained in:
parent
ddadcc9ea0
commit
c6b62b82d4
1 changed files with 8 additions and 0 deletions
|
@ -105,6 +105,7 @@ enum PlayerCommand {
|
||||||
Pause,
|
Pause,
|
||||||
Stop,
|
Stop,
|
||||||
Seek(u32),
|
Seek(u32),
|
||||||
|
SetSession(Session),
|
||||||
AddEventSender(mpsc::UnboundedSender<PlayerEvent>),
|
AddEventSender(mpsc::UnboundedSender<PlayerEvent>),
|
||||||
SetSinkEventCallback(Option<SinkEventCallback>),
|
SetSinkEventCallback(Option<SinkEventCallback>),
|
||||||
EmitVolumeChangedEvent(u16),
|
EmitVolumeChangedEvent(u16),
|
||||||
|
@ -538,6 +539,10 @@ impl Player {
|
||||||
self.command(PlayerCommand::Seek(position_ms));
|
self.command(PlayerCommand::Seek(position_ms));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_session(&self, session: Session) {
|
||||||
|
self.command(PlayerCommand::SetSession(session));
|
||||||
|
}
|
||||||
|
|
||||||
pub fn get_player_event_channel(&self) -> PlayerEventChannel {
|
pub fn get_player_event_channel(&self) -> PlayerEventChannel {
|
||||||
let (event_sender, event_receiver) = mpsc::unbounded_channel();
|
let (event_sender, event_receiver) = mpsc::unbounded_channel();
|
||||||
self.command(PlayerCommand::AddEventSender(event_sender));
|
self.command(PlayerCommand::AddEventSender(event_sender));
|
||||||
|
@ -2092,6 +2097,8 @@ impl PlayerInternal {
|
||||||
|
|
||||||
PlayerCommand::Stop => self.handle_player_stop(),
|
PlayerCommand::Stop => self.handle_player_stop(),
|
||||||
|
|
||||||
|
PlayerCommand::SetSession(session) => self.session = session,
|
||||||
|
|
||||||
PlayerCommand::AddEventSender(sender) => self.event_senders.push(sender),
|
PlayerCommand::AddEventSender(sender) => self.event_senders.push(sender),
|
||||||
|
|
||||||
PlayerCommand::SetSinkEventCallback(callback) => self.sink_event_callback = callback,
|
PlayerCommand::SetSinkEventCallback(callback) => self.sink_event_callback = callback,
|
||||||
|
@ -2282,6 +2289,7 @@ impl fmt::Debug for PlayerCommand {
|
||||||
PlayerCommand::Pause => f.debug_tuple("Pause").finish(),
|
PlayerCommand::Pause => f.debug_tuple("Pause").finish(),
|
||||||
PlayerCommand::Stop => f.debug_tuple("Stop").finish(),
|
PlayerCommand::Stop => f.debug_tuple("Stop").finish(),
|
||||||
PlayerCommand::Seek(position) => f.debug_tuple("Seek").field(&position).finish(),
|
PlayerCommand::Seek(position) => f.debug_tuple("Seek").field(&position).finish(),
|
||||||
|
PlayerCommand::SetSession(_) => f.debug_tuple("SetSession").finish(),
|
||||||
PlayerCommand::AddEventSender(_) => f.debug_tuple("AddEventSender").finish(),
|
PlayerCommand::AddEventSender(_) => f.debug_tuple("AddEventSender").finish(),
|
||||||
PlayerCommand::SetSinkEventCallback(_) => {
|
PlayerCommand::SetSinkEventCallback(_) => {
|
||||||
f.debug_tuple("SetSinkEventCallback").finish()
|
f.debug_tuple("SetSinkEventCallback").finish()
|
||||||
|
|
Loading…
Reference in a new issue