[][src]Struct serenity::voice::Audio

pub struct Audio {
    pub playing: bool,
    pub volume: f32,
    pub finished: bool,
    pub source: Box<dyn AudioSource>,
    pub position: Duration,
    pub position_modified: bool,
}

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

This example is not tested
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

Whether or not this sound is currently playing.

Can be controlled with play or pause if chaining is desired.

The desired volume for playback.

Sensible values fall between 0.0 and 1.0. Can be controlled with volume if chaining is desired.

Whether or not the sound has finished, or reached the end of its stream.

Read-only for now.

Underlying data access object.

Calling code is not expected to use this.

The current position for playback.

Consider the position fields read-only for now.

Methods

impl Audio
[src]

Sets playing to true in a manner that allows method chaining.

Sets playing to false in a manner that allows method chaining.

Sets volume in a manner that allows method chaining.

Change the position in the stream for subsequent playback.

Currently a No-op.

Auto Trait Implementations

impl Send for Audio

impl !Sync for Audio

Blanket Implementations

impl<T, U> Into for T where
    U: From<T>, 
[src]

Performs the conversion.

impl<T> From for T
[src]

Performs the conversion.

impl<T, U> TryFrom for T where
    T: From<U>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> Borrow for T where
    T: ?Sized
[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut for T where
    T: ?Sized
[src]

Mutably borrows from an owned value. Read more

impl<T, U> TryInto for T where
    U: TryFrom<T>, 
[src]

🔬 This is a nightly-only experimental API. (try_from)

The type returned in the event of a conversion error.

🔬 This is a nightly-only experimental API. (try_from)

Performs the conversion.

impl<T> Any for T where
    T: 'static + ?Sized
[src]

🔬 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> Typeable for T where
    T: Any

Get the TypeId of this object.

impl<T> UnsafeAny for T where
    T: Any