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.
Track
s 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: PlayMode
Whether or not this sound is currently playing.
Defaults to PlayMode::Play
.
volume: f32
The 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: Input
The live or lazily-initialised audio stream to be played.
events: 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.
Defaults to an empty set.
loops: LoopState
Count of remaining loops.
Defaults to play a track once (i.e., LoopState::Finite(0)
).
uuid: Uuid
Unique 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.