[−][src]Struct serenity::voice::Audio
Control object for audio playback.
Accessed by both commands and the playback code -- as such, access is
always guarded. In particular, you should expect to receive
a LockedAudio
when calling Handler::play_returning
or
Handler::play_only
.
Example
use serenity::voice::{Handler, LockedAudio, ffmpeg}; let handler: Handler = /* ... */; let source = ffmpeg("../audio/my-favourite-song.mp3")?; let safe_audio: LockedAudio = handler.play_only(); { let audio_lock = safe_audio_control.clone(); let mut audio = audio_lock.lock(); audio.volume(0.5); }
Fields
playing: bool
Whether or not this sound is currently playing.
Can be controlled with play
or pause
if chaining is desired.
volume: f32
The desired volume for playback.
Sensible values fall between 0.0
and 1.0
.
Can be controlled with volume
if chaining is desired.
finished: bool
Whether or not the sound has finished, or reached the end of its stream.
Read-only for now.
source: Box<dyn AudioSource>
Underlying data access object.
Calling code is not expected to use this.
position: Duration
The current position for playback.
Consider the position fields read-only for now.
position_modified: bool
Methods
impl Audio
[src]
impl Audio
pub fn new(source: Box<dyn AudioSource>) -> Self
[src]
pub fn new(source: Box<dyn AudioSource>) -> Self
pub fn play(&mut self) -> &mut Self
[src]
pub fn play(&mut self) -> &mut Self
Sets playing
to true
in a manner that allows method chaining.
pub fn pause(&mut self) -> &mut Self
[src]
pub fn pause(&mut self) -> &mut Self
Sets playing
to false
in a manner that allows method chaining.
pub fn volume(&mut self, volume: f32) -> &mut Self
[src]
pub fn volume(&mut self, volume: f32) -> &mut Self
Sets volume
in a manner that allows method chaining.
pub fn position(&mut self, position: Duration) -> &mut Self
[src]
pub fn position(&mut self, position: Duration) -> &mut Self
Change the position in the stream for subsequent playback.
Currently a No-op.
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
impl<T, U> Into for T where
U: From<T>,
impl<T> From for T
[src]
impl<T> From for T
impl<T, U> TryFrom for T where
T: From<U>,
[src]
impl<T, U> TryFrom for T where
T: From<U>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
try_from
)Performs the conversion.
impl<T> Borrow for T where
T: ?Sized,
[src]
impl<T> Borrow for T where
T: ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
impl<T> BorrowMut for T where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
try_from
)Performs the conversion.
impl<T> Any for T where
T: 'static + ?Sized,
[src]
impl<T> Any for T where
T: 'static + ?Sized,
fn get_type_id(&self) -> TypeId
[src]
fn get_type_id(&self) -> TypeId
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static
Gets the TypeId
of self
. Read more
impl<T> Erased for T
impl<T> Erased for T
impl<T> Typeable for T where
T: Any,
impl<T> Typeable for T where
T: Any,
impl<T> UnsafeAny for T where
T: Any,
impl<T> UnsafeAny for T where
T: Any,