pub struct Track {
pub playing: PlayMode,
pub volume: f32,
pub input: Input,
pub events: EventStore,
pub loops: LoopState,
pub uuid: Uuid,
pub user_data: Arc<dyn Any + Send + Sync>,
}Expand description
Initial state for audio playback.
Tracks allow you to configure play modes, volume, event handlers, and other track state
before you pass an input to the Driver.
Live track data is accessed via a TrackHandle, which is returned by Driver::play and
related methods.
§Example
use songbird::{driver::Driver, input::File, tracks::Track};
// A Call is also valid here!
let mut driver: Driver = Default::default();
let source = File::new("../audio/my-favourite-song.mp3");
let handle = driver.play_only(Track::from(source).volume(0.5));
// Future access occurs via audio.Fields§
§playing: PlayModeWhether or not this sound is currently playing.
Defaults to PlayMode::Play.
volume: f32The volume for playback.
Sensible values fall between 0.0 and 1.0. Values outside this range can
cause clipping or other audio artefacts.
Defaults to 1.0.
input: InputThe live or lazily-initialised audio stream to be played.
events: EventStoreList 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.
Defaults to an empty set.
loops: LoopStateCount of remaining loops.
Defaults to play a track once (i.e., LoopState::Finite(0)).
uuid: UuidUnique identifier for this track.
Defaults to a random 128-bit number.
user_data: Arc<dyn Any + Send + Sync>Any data to be associated with the track.
Implementations§
Source§impl Track
impl Track
Sourcepub fn new_with_uuid(input: Input, uuid: Uuid) -> Self
pub fn new_with_uuid(input: Input, uuid: Uuid) -> Self
Sourcepub fn new_with_data(
input: Input,
user_data: Arc<dyn Any + Send + Sync + 'static>,
) -> Self
pub fn new_with_data( input: Input, user_data: Arc<dyn Any + Send + Sync + 'static>, ) -> Self
Sourcepub fn new_with_uuid_and_data(
input: Input,
uuid: Uuid,
user_data: Arc<dyn Any + Send + Sync + 'static>,
) -> Self
pub fn new_with_uuid_and_data( input: Input, uuid: Uuid, user_data: Arc<dyn Any + Send + Sync + 'static>, ) -> Self
Sourcepub fn pause(self) -> Self
pub fn pause(self) -> Self
Pre-emptively pauses a track, preventing it from being automatically played.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Track
impl !RefUnwindSafe for Track
impl Send for Track
impl !Sync for Track
impl Unpin for Track
impl UnsafeUnpin for Track
impl !UnwindSafe for Track
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Classify for T
impl<T> Classify for T
type Classified = T
fn classify(self) -> T
§impl<T> Declassify for T
impl<T> Declassify for T
type Declassified = T
fn declassify(self) -> T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more