Trait IAudioStreamPlayback
pub trait IAudioStreamPlayback: GodotClass<Base = AudioStreamPlayback> + You_forgot_the_attribute__godot_api {
Show 18 methods
// Required methods
fn start(&mut self, from_pos: f64);
fn stop(&mut self);
fn is_playing(&self) -> bool;
fn get_playback_position(&self) -> f64;
unsafe fn mix_rawptr(
&mut self,
buffer: RawPtr<*mut AudioFrame>,
rate_scale: f32,
frames: i32,
) -> i32;
// Provided methods
fn init(base: Base<Self::Base>) -> Self { ... }
fn on_notification(&mut self, what: ObjectNotification) { ... }
fn on_get(&self, property: StringName) -> Option<Variant> { ... }
fn on_set(&mut self, property: StringName, value: Variant) -> bool { ... }
fn on_validate_property(&self, property: &mut PropertyInfo) { ... }
fn on_get_property_list(&mut self) -> Vec<PropertyInfo> { ... }
fn on_property_get_revert(&self, property: StringName) -> Option<Variant> { ... }
fn to_string(&self) -> GString { ... }
fn get_loop_count(&self) -> i32 { ... }
fn seek(&mut self, position: f64) { ... }
fn tag_used_streams(&mut self) { ... }
fn set_parameter(&mut self, name: StringName, value: Variant) { ... }
fn get_parameter(&self, name: StringName) -> Variant { ... }
}Expand description
§Interface trait for class AudioStreamPlayback.
Functions in this trait represent constructors (init) or virtual method callbacks invoked by the engine.
§Related symbols
Base interfaces: IRefCounted > IObject.
Required Methods§
fn start(&mut self, from_pos: f64)
fn start(&mut self, from_pos: f64)
Override this method to customize what happens when the playback starts at the given position, such as by calling play.
fn stop(&mut self)
fn stop(&mut self)
Override this method to customize what happens when the playback is stopped, such as by calling stop.
fn is_playing(&self) -> bool
fn is_playing(&self) -> bool
Overridable method. Should return true if this playback is active and playing its audio stream.
fn get_playback_position(&self) -> f64
fn get_playback_position(&self) -> f64
Overridable method. Should return the current progress along the audio stream, in seconds.
unsafe fn mix_rawptr(
&mut self,
buffer: RawPtr<*mut AudioFrame>,
rate_scale: f32,
frames: i32,
) -> i32
unsafe fn mix_rawptr( &mut self, buffer: RawPtr<*mut AudioFrame>, rate_scale: f32, frames: i32, ) -> i32
§Godot docs
Override this method to customize how the audio stream is mixed. This method is called even if the playback is not active.
Note: It is not useful to override this method in GDScript or C#. Only GDExtension can take advantage of it.
§Safety
This method has automatically been marked unsafe because it accepts raw pointers as parameters.
If Godot does not document any safety requirements, make sure you understand the underlying semantics.
Provided Methods§
fn init(base: Base<Self::Base>) -> Self
fn init(base: Base<Self::Base>) -> Self
Godot constructor, accepting an injected base object.
base refers to the base instance of the class, which can either be stored in a Base<T> field or discarded.
This method returns a fully-constructed instance, which will then be moved into a Gd<T> pointer.
If the class has a #[class(init)] attribute, this method will be auto-generated and must not be overridden.
fn on_notification(&mut self, what: ObjectNotification)
fn on_notification(&mut self, what: ObjectNotification)
Called when the object receives a Godot notification.
The type of notification can be identified through what. The enum is designed to hold all possible NOTIFICATION_*
constants that the current class can handle. However, this is not validated in Godot, so an enum variant Unknown exists
to represent integers out of known constants (mistakes or future additions).
This method is named _notification in Godot, but on_notification in Rust. To send notifications, use the
Object::notify method.
See also in Godot docs:
fn on_get(&self, property: StringName) -> Option<Variant>
fn on_get(&self, property: StringName) -> Option<Variant>
Called whenever get() is called or Godot gets the value of a property.
Should return the given property’s value as Some(value), or None if the property should be handled normally.
See also in Godot docs:
fn on_set(&mut self, property: StringName, value: Variant) -> bool
fn on_set(&mut self, property: StringName, value: Variant) -> bool
Called whenever Godot set() is called or Godot sets the value of a property.
Should set property to the given value and return true, or return false to indicate the property
should be handled normally.
See also in Godot docs:
fn on_validate_property(&self, property: &mut PropertyInfo)
fn on_validate_property(&self, property: &mut PropertyInfo)
Called whenever Godot retrieves value of property. Allows to customize existing properties.
Every property info goes through this method, except properties added with on_get_property_list().
Exposed property here is a shared mutable reference obtained (and returned to) from Godot.
See also in the Godot docs:
fn on_get_property_list(&mut self) -> Vec<PropertyInfo>
Available on since_api=4.3 only.
fn on_get_property_list(&mut self) -> Vec<PropertyInfo>
since_api=4.3 only.Called whenever Godot get_property_list() is called, the returned vector here is
appended to the existing list of properties.
This should mainly be used for advanced purposes, such as dynamically updating the property list in the editor.
See also in Godot docs:
fn on_property_get_revert(&self, property: StringName) -> Option<Variant>
fn on_property_get_revert(&self, property: StringName) -> Option<Variant>
Called by Godot to tell if a property has a custom revert or not.
Return None for no custom revert, and return Some(value) to specify the custom revert.
This is a combination of Godot’s Object::_property_get_revert and Object::_property_can_revert. This means that this
function will usually be called twice by Godot to find the revert.
Note that this should be a pure function. That is, it should always return the same value for a property as long as self
remains unchanged. Otherwise, this may lead to unexpected (safe) behavior.
fn to_string(&self) -> GString
fn to_string(&self) -> GString
String representation of the Godot instance.
Override this method to define how the instance is represented as a string.
Used by impl Display for Gd<T>, as well as str() and print() in GDScript.
fn get_loop_count(&self) -> i32
fn get_loop_count(&self) -> i32
Overridable method. Should return how many times this audio stream has looped. Most built-in playbacks always return 0.
fn seek(&mut self, position: f64)
fn seek(&mut self, position: f64)
Override this method to customize what happens when seeking this audio stream at the given position, such as by calling seek.
fn tag_used_streams(&mut self)
fn tag_used_streams(&mut self)
Overridable method. Called whenever the audio stream is mixed if the playback is active and set_enable_tagging_used_audio_streams has been set to true. Editor plugins may use this method to “tag” the current position along the audio stream and display it in a preview.
fn set_parameter(&mut self, name: StringName, value: Variant)
fn set_parameter(&mut self, name: StringName, value: Variant)
Set the current value of a playback parameter by name (see get_parameter_list).
fn get_parameter(&self, name: StringName) -> Variant
fn get_parameter(&self, name: StringName) -> Variant
Return the current value of a playback parameter by name (see get_parameter_list).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.