Struct ark_api::world::AudioSource
source · [−]pub struct AudioSource { /* private fields */ }
Expand description
AudioSource
component.
Lets you emit audio from an entity.
Usually accessed through entity.audio_source
().
Implementations
sourceimpl AudioSource
impl AudioSource
sourcepub fn dynamic_module_data(&self) -> ValueAccessorDataReadWrite<BinaryData>
pub fn dynamic_module_data(&self) -> ValueAccessorDataReadWrite<BinaryData>
Returns a ValueAccessor
for setting dynamic data that is passed to a module.
Data is expected to be of type “Binary”
Used to set/get the dynamic data. Sets which audio clip is attached to the AudioSource component of this entity (assuming it has one).
sourcepub fn clip(&self) -> ValueAccessorDataReadWrite<AudioClip>
pub fn clip(&self) -> ValueAccessorDataReadWrite<AudioClip>
Returns a ValueAccessor
for the audio clip from which the AudioSource component should play audio.
Used to set/get the audio clip. Sets which audio clip is attached to the AudioSource component of this entity (assuming it has one).
sourcepub fn volume(&self) -> ValueAccessorReadWriteAnimate<f32>
pub fn volume(&self) -> ValueAccessorReadWriteAnimate<f32>
Controls the volume of the audio source
sourcepub fn rate(&self) -> ValueAccessorReadWriteAnimate<f32>
pub fn rate(&self) -> ValueAccessorReadWriteAnimate<f32>
Controls what sample rate to read a clip with. In other words the speed at which the clip is played.
sourcepub fn looping(&self) -> ValueAccessorReadWrite<bool>
pub fn looping(&self) -> ValueAccessorReadWrite<bool>
Controls whether the playing clip will loop
sourcepub fn force_2d(&self) -> ValueAccessorReadWrite<bool>
pub fn force_2d(&self) -> ValueAccessorReadWrite<bool>
Will center the sound at the head position.
sourcepub fn allow_interruption(&self) -> ValueAccessorReadWrite<bool>
pub fn allow_interruption(&self) -> ValueAccessorReadWrite<bool>
If set to false will not respond to play()
until the currently playing sound has finished.
sourcepub fn stop_on_destroy(&self) -> ValueAccessorReadWrite<bool>
pub fn stop_on_destroy(&self) -> ValueAccessorReadWrite<bool>
If set to false, will not stop audio when the owning entity gets destroyed. Will only work for non-looping sounds.
sourcepub fn player_id_set(&self) -> ValueAccessorDataReadWrite<PlayerIdSet>
pub fn player_id_set(&self) -> ValueAccessorDataReadWrite<PlayerIdSet>
Returns a ValueAccessor
for the set of player ids this audio source should be played for.
Used to set/get the player id set. Sets which player id set is attached to the render component of this entity (assuming it has one).
sourcepub fn is_playing(&self) -> ValueAccessorRead<bool>
pub fn is_playing(&self) -> ValueAccessorRead<bool>
Returns a ValueAccessor
for the AudioSource
“is playing” state.
Used to get whether audio is playing or not. It will be set to false
if the sound has reached to its end, unless the
AudioSource
is set to be looping. If the AudioSource
is set to be looping it will only be false
if stop
has been called.
sourcepub fn play(&self)
pub fn play(&self)
Starts playing audio from this audio source.
Will stop audio currently playing on this audio source unless allow_interruption
is set to false.
This acts as if a speaker connected to a tape player is attached to the entity.
sourcepub fn play_one_shot(
position: Option<Vec3>,
clip: &AudioClip,
volume: f32,
rate: f32
)
pub fn play_one_shot(
position: Option<Vec3>,
clip: &AudioClip,
volume: f32,
rate: f32
)
Starts playing audio at a specified world position, or attached to the listener’s world position if None
.
After it’s started there’s no way to stop or modify that audio signal. It will play the clip
once at the location. Looping is not supported for this.
This acts as if a speaker connected to a tape player is either left at the specified world position or attached to the listener (2d).
position
- Sets the position of the audio source. If None
it will be playing at the position of the listener.
clip
- Sets the audio clip of the audio source for this one shot.
volume
- Sets the volume of this one shot
rate
- Sets the sample rate at which the clip is read with. In other words the speed at which the clip is played.
Trait Implementations
sourceimpl ComponentTrait for AudioSource
impl ComponentTrait for AudioSource
sourcefn get_type() -> ComponentType
fn get_type() -> ComponentType
The type of the component, as a ComponentType
enum.
sourcefn from_entity(handle: Entity) -> Self
fn from_entity(handle: Entity) -> Self
Adopt an Entity
, wrap in a component struct.
Auto Trait Implementations
impl RefUnwindSafe for AudioSource
impl Send for AudioSource
impl Sync for AudioSource
impl Unpin for AudioSource
impl UnwindSafe for AudioSource
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more