From 9c77ab0467ea039d482e909880fe9e9b44a83635 Mon Sep 17 00:00:00 2001 From: Jordan Doyle Date: Sun, 23 Feb 2020 21:13:24 +0000 Subject: [PATCH] Provide a way for Speakers to group with a master --- src/device.rs | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/src/device.rs b/src/device.rs index 40a488d..c1a128c 100644 --- a/src/device.rs +++ a/src/device.rs @@ -397,11 +397,32 @@ }) } + /// Groups this Speaker with the given master. + /// + /// This speaker will be synchronised with the master. + pub async fn group(&self, master: &Speaker) -> Result<(), Error> { + self.play_track(&format!("x-rincon:{}", master.uuid)).await + } + + /// Ungroups this Speaker from any master it might've had. + pub async fn ungroup(&self) -> Result<(), Error> { + self.soap( + "MediaRenderer/AVTransport/Control", + "urn:schemas-upnp-org:service:AVTransport:1", + "BecomeCoordinatorOfStandaloneGroup", + "0", + true, + ).await?; + + Ok(()) + } + + /// Grab this Speaker's queue to manipulate. pub fn queue(&self) -> Queue { Queue::for_speaker(self) } - /// Get information about the current track + /// Get information about what's currently playing on this Speaker. pub async fn track(&self) -> Result { let resp = self.soap( "MediaRenderer/AVTransport/Control", @@ -458,6 +479,7 @@ } } +/// An item in the queue. pub struct QueueItem { pub position: u64, pub uri: String, @@ -468,6 +490,8 @@ pub duration: Duration, } +/// Provides some methods for manipulating the queue of the +/// [Speaker] that spawned this [Queue]. pub struct Queue<'a> { speaker: &'a Speaker, } -- rgit 0.1.3