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§

source§

impl AudioSource

source

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).

source

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).

source

pub fn volume(&self) -> ValueAccessorReadWriteAnimate<f32>

Controls the volume of the audio source

source

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.

source

pub fn looping(&self) -> ValueAccessorReadWrite<bool>

Controls whether the playing clip will loop

source

pub fn force_2d(&self) -> ValueAccessorReadWrite<bool>

Will center the sound at the head position.

source

pub fn allow_interruption(&self) -> ValueAccessorReadWrite<bool>

If set to false will not respond to play() until the currently playing sound has finished.

source

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.

source

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).

source

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.

source

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.

source

pub fn stop(&self)

Stops playing audio from this audio source.

source

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§

source§

impl ComponentTrait for AudioSource

source§

fn get_type() -> ComponentType

The type of the component, as a ComponentType enum.
source§

fn from_entity(handle: Entity) -> Self

Adopt an Entity, wrap in a component struct.
source§

fn try_from_entity(handle: Entity) -> Option<Self>

Try to adopt an Entity, wrapping it in a component struct.
source§

fn entity(&self) -> Entity

Get the entity that the component belongs to.
source§

impl Debug for AudioSource

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.