[−][src]Struct songbird::driver::Driver
The control object for a Discord voice connection, handling connection, mixing, encoding, en/decryption, and event generation.
When compiled with the "builtin-queue"
feature, each driver includes a track queue
as a convenience to prevent the additional overhead of per-guild state management.
Implementations
impl Driver
[src]
pub fn new(config: Config) -> Self
[src]
Creates a new voice driver.
This will create the core voice tasks in the background.
pub fn connect(&mut self, info: ConnectionInfo) -> Connectⓘ
[src]
Connects to a voice channel using the specified server.
This method instantly contacts the driver tasks, and its
does not need to be await
ed to start the actual connection.
pub fn leave(&mut self)
[src]
Leaves the current voice channel, disconnecting from it.
This does not forget settings, like whether to be self-deafened or self-muted.
pub fn mute(&mut self, mute: bool)
[src]
Sets whether the current connection is to be muted.
If there is no live voice connection, then this only acts as a settings update for future connections.
pub fn is_mute(&self) -> bool
[src]
Returns whether the driver is muted (i.e., processes audio internally but submits none).
pub fn play_source(&mut self, source: Input) -> TrackHandle
[src]
Plays audio from a source, returning a handle for further control.
pub fn play_only_source(&mut self, source: Input) -> TrackHandle
[src]
Plays audio from a source, returning a handle for further control.
Unlike play_source
, this stops all other sources attached
to the channel.
pub fn play(&mut self, track: Track)
[src]
Plays audio from a Track
object.
This will be one half of the return value of create_player
.
The main difference between this function and play_source
is
that this allows for direct manipulation of the Track
object
before it is passed over to the voice and mixing contexts.
pub fn play_only(&mut self, track: Track)
[src]
Exclusively plays audio from a Track
object.
This will be one half of the return value of create_player
.
As in play_only_source
, this stops all other sources attached to the
channel. Like play
, however, this allows for direct manipulation of the
Track
object before it is passed over to the voice and mixing contexts.
pub fn set_bitrate(&mut self, bitrate: Bitrate)
[src]
Sets the bitrate for encoding Opus packets sent along the channel being managed.
The default rate is 128 kbps.
Sensible values range between Bits(512)
and Bits(512_000)
bits per second.
Alternatively, Auto
and Max
remain available.
pub fn stop(&mut self)
[src]
Stops playing audio from all sources, if any are set.
pub fn set_config(&mut self, config: Config)
[src]
Sets the configuration for this driver.
pub fn add_global_event<F: EventHandler + 'static>(
&mut self,
event: Event,
action: F
)
[src]
&mut self,
event: Event,
action: F
)
Attach a global event handler to an audio context. Global events may receive
any EventContext
.
Global timing events will tick regardless of whether audio is playing,
so long as the bot is connected to a voice channel, and have no tracks.
TrackEvent
s will respond to all relevant tracks, giving some audio elements.
Users must ensure that no costly work or blocking occurs within the supplied function or closure. Taking excess time could prevent timely sending of packets, causing audio glitches and delays.
impl Driver
[src]
pub fn queue(&self) -> &TrackQueue
[src]
Returns a reference to this driver's built-in queue.
Requires the "builtin-queue"
feature.
Queue additions should be made via enqueue
and
enqueue_source
.
pub fn enqueue_source(&mut self, source: Input)
[src]
Adds an audio Input
to this driver's built-in queue.
Requires the "builtin-queue"
feature.
pub fn enqueue(&mut self, track: Track)
[src]
Adds an existing Track
to this driver's built-in queue.
Requires the "builtin-queue"
feature.
Trait Implementations
impl Clone for Driver
[src]
impl Debug for Driver
[src]
impl Default for Driver
[src]
impl Drop for Driver
[src]
Auto Trait Implementations
impl !RefUnwindSafe for Driver
[src]
impl Send for Driver
[src]
impl Sync for Driver
[src]
impl Unpin for Driver
[src]
impl !UnwindSafe for Driver
[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,
pub fn vzip(self) -> V
impl<T> WithSubscriber for T
[src]
pub fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
[src]
S: Into<Dispatch>,