StreamPlayer

Inherits: Node < Object

Category: Core

Brief Description

Base class for audio stream playback.

Member Functions

int

get_buffering_msec ( ) const

float

get_length ( ) const

int

get_loop_count ( ) const

float

get_loop_restart_time ( ) const

float

get_pos ( ) const

AudioStream

get_stream ( ) const

String

get_stream_name ( ) const

float

get_volume ( ) const

float

get_volume_db ( ) const

bool

has_autoplay ( ) const

bool

has_loop ( ) const

bool

is_paused ( ) const

bool

is_playing ( ) const

void

play ( float offset=0 )

void

seek_pos ( float time )

void

set_autoplay ( bool enabled )

void

set_buffering_msec ( int msec )

void

set_loop ( bool enabled )

void

set_loop_restart_time ( float secs )

void

set_paused ( bool paused )

void

set_stream ( AudioStream stream )

void

set_volume ( float volume )

void

set_volume_db ( float db )

void

stop ( )

Signals

  • finished ( )

This signal triggers when the player stops playing. It will not trigger on each loop.

Description

Base class for audio stream playback. Audio stream players inherit from it.

Member Function Description

  • int get_buffering_msec ( ) const

Return the size of the audio buffer.

  • float get_length ( ) const

Return the length of the stream, in seconds.

  • int get_loop_count ( ) const

Return the number of times the playback has looped.

  • float get_loop_restart_time ( ) const

Return the point in time the stream will rewind to, when looping.

  • float get_pos ( ) const

Return the playback position, in seconds.

Return the currently assigned stream.

  • String get_stream_name ( ) const

Return the name of the currently assigned stream. This is not the file name, but a field inside the file. If no stream is assigned, if returns “<No Stream>”.

  • float get_volume ( ) const

Return the playback volume for this player.

  • float get_volume_db ( ) const

Return the playback volume for this player, in decibels.

  • bool has_autoplay ( ) const

Return whether this player will start playing as soon as it enters the scene tree.

  • bool has_loop ( ) const

Return whether the stream will be restarted at the end.

  • bool is_paused ( ) const

Return whether the playback is currently paused.

  • bool is_playing ( ) const

Return whether this player is playing.

  • void play ( float offset=0 )

Play the currently assigned stream, starting from a given position (in seconds).

  • void seek_pos ( float time )

Set the playback position, in seconds.

  • void set_autoplay ( bool enabled )

Set whether this player will start playing as soon as it enters the scene tree.

  • void set_buffering_msec ( int msec )

Set the size (in milliseconds) of the audio buffer. A long audio buffer protects better against slowdowns, but responds worse to changes (in volume, stream played…). A shorter buffer takes less time to respond to changes, but may stutter if the application suffers some slowdown.

Default is 500 milliseconds.

  • void set_loop ( bool enabled )

Set whether the stream will be restarted at the end.

  • void set_loop_restart_time ( float secs )

Set the point in time the stream will rewind to, when looping.

  • void set_paused ( bool paused )

Pause stream playback.

Set the EventStream this player will play.

  • void set_volume ( float volume )

Set the playback volume for this player. This is a float between 0.0 (silent) and 1.0 (full volume). Values over 1.0 will amplify sound even more, but may introduce distortion. Negative values will just invert the output waveform, which produces no audible difference.

  • void set_volume_db ( float db )

Set the playback volume for this player, in decibels. This is a float between -80.0 (silent) and 0.0 (full volume). Values under -79.0 get truncated to -80, but values over 0.0 do not, so the warnings for overamplifying (see set_volume) still apply.

  • void stop ( )

Stop the playback.