logo
pub struct AudioSource { /* private fields */ }
Expand description

AudioSource component.

Lets you emit audio from an entity. Usually accessed through entity.audio_source().

Implementations

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

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

Controls the volume of the audio source

Controls what sample rate to read a clip with. In other words the speed at which the clip is played.

Controls whether the playing clip will loop

Will center the sound at the head position.

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

If set to false, will not stop audio when the owning entity gets destroyed. Will only work for non-looping sounds.

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

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.

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.

Stops playing audio from this audio source.

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

The type of the component, as a ComponentType enum.

Adopt an Entity, wrap in a component struct.

Get the entity that the component belongs to.

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.