Struct songbird::tracks::Track[][src]

pub struct Track {
    pub events: Option<EventStore>,
    pub handle: TrackHandle,
    pub loops: LoopState,
    // some fields omitted
}

Control object for audio playback.

Accessed by both commands and the playback code – as such, access from user code is almost always guarded via a TrackHandle. You should expect to receive access to a raw object of this type via create_player, for use in Driver::play or Driver::play_only.

Example

use songbird::{driver::Driver, ffmpeg, tracks::create_player};

// A Call is also valid here!
let mut handler: Driver = Default::default();
let source = ffmpeg("../audio/my-favourite-song.mp3")
    .await
    .expect("This might fail: handle this error!");
let (mut audio, audio_handle) = create_player(source);

audio.set_volume(0.5);

handler.play_only(audio);

// Future access occurs via audio_handle.

Fields

events: Option<EventStore>

List of events attached to this audio track.

This may be used to add additional events to a track before it is sent to the audio context for playing.

handle: TrackHandle

Handle for safe control of this audio track from other threads.

Typically, this is used by internal code to supply context information to event handlers, though more may be cloned from this handle.

loops: LoopState

Count of remaining loops.

Implementations

impl Track[src]

pub fn new_raw(
    source: Input,
    commands: Receiver<TrackCommand>,
    handle: TrackHandle
) -> Self
[src]

Create a new track directly from an input, command source, and handle.

In general, you should probably use create_player.

pub fn play(&mut self) -> &mut Self[src]

Sets a track to playing if it is paused.

pub fn pause(&mut self) -> &mut Self[src]

Pauses a track if it is playing.

pub fn stop(&mut self) -> &mut Self[src]

Manually stops a track.

This will cause the audio track to be removed, with any relevant events triggered. Stopped/ended tracks cannot be restarted.

pub fn playing(&self) -> PlayMode[src]

Returns the current play status of this track.

pub fn set_volume(&mut self, volume: f32) -> &mut Self[src]

Sets volume in a manner that allows method chaining.

pub fn volume(&self) -> f32[src]

Returns the current playback position.

pub fn position(&self) -> Duration[src]

Returns the current playback position.

pub fn play_time(&self) -> Duration[src]

Returns the total length of time this track has been active.

pub fn set_loops(&mut self, loops: LoopState) -> TrackResult<()>[src]

Set an audio track to loop a set number of times.

If the underlying Input does not support seeking, then all calls will fail with TrackError::SeekUnsupported.

pub fn make_playable(&mut self)[src]

Ready a track for playing if it is lazily initialised.

Currently, only Restartable sources support lazy setup. This call is a no-op for all others.

pub fn state(&self) -> TrackState[src]

Creates a read-only copy of the audio track’s state.

The primary use-case of this is sending information across threads in response to a TrackHandle.

pub fn seek_time(&mut self, pos: Duration) -> TrackResult<Duration>[src]

Seek to a specific point in the track.

If the underlying Input does not support seeking, then all calls will fail with TrackError::SeekUnsupported.

pub fn uuid(&self) -> Uuid[src]

Returns this track’s unique identifier.

Trait Implementations

impl Debug for Track[src]

Auto Trait Implementations

impl !RefUnwindSafe for Track

impl Send for Track

impl !Sync for Track

impl Unpin for Track

impl !UnwindSafe for Track

Blanket Implementations

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

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

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

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

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

impl<T> Same<T> for T

type Output = T

Should always be Self

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

type Error = Infallible

The type returned in the event of a conversion error.

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

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

impl<T> WithSubscriber for T[src]