Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
VideoStreamPlayback¶
继承: Resource < RefCounted < Object
VideoStream 使用的内部类,用于管理其在 VideoStreamPlayer 中的播放状态。
描述¶
该类旨在被具有 VideoStream 自定义实现的视频解码器扩展所覆盖。
方法¶
_get_channels ( ) virtual const |
|
_get_length ( ) virtual const |
|
_get_mix_rate ( ) virtual const |
|
_get_playback_position ( ) virtual const |
|
_get_texture ( ) virtual const |
|
_is_paused ( ) virtual const |
|
_is_playing ( ) virtual const |
|
void |
_play ( ) virtual |
void |
|
void |
_set_audio_track ( int idx ) virtual |
void |
_set_paused ( bool paused ) virtual |
void |
_stop ( ) virtual |
void |
|
mix_audio ( int num_frames, PackedFloat32Array buffer=PackedFloat32Array(), int offset=0 ) |
方法说明¶
int _get_channels ( ) virtual const
返回音频通道的数量。
float _get_length ( ) virtual const
视频时长已知时返回视频时长,未知时返回 0。
int _get_mix_rate ( ) virtual const
返回用于混音的音频采样率。
float _get_playback_position ( ) virtual const
返回当前播放时间戳。获取 VideoStreamPlayer.stream_position 时会被调用。
Texture2D _get_texture ( ) virtual const
分配一个 Texture2D,解码得到的视频帧会在其中绘制。
bool _is_paused ( ) virtual const
返回暂停状态,由 _set_paused 设置。
bool _is_playing ( ) virtual const
void _play ( ) virtual
VideoStreamPlayer.autoplay 或 VideoStreamPlayer.play 时会被调用。请注意,手动播放在这个方法被调用前也可能多次调用 _stop。开始播放后 _is_playing 就应该返回 true。
void _seek ( float time ) virtual
检索至第 time
秒。设置 VideoStreamPlayer.stream_position 时会被调用。
void _set_audio_track ( int idx ) virtual
选择 idx
音轨。播放开始时,或者设置 VideoStreamPlayer.audio_track 时会被调用。
void _set_paused ( bool paused ) virtual
设置视频播放的暂停状态。_is_paused 必须返回 paused
。设置 VideoStreamPlayer.paused 时会被调用。
void _stop ( ) virtual
停止播放。可能在 _play 多次调用,也可能与 VideoStreamPlayer.stop 对应。停止后 _is_playing 应返回 false。
void _update ( float delta ) virtual
将视频播放推进 delta
秒。只要 _is_paused 和 _is_playing 返回 true,就会为每一帧调用。
int mix_audio ( int num_frames, PackedFloat32Array buffer=PackedFloat32Array(), int offset=0 )
从数组中的索引 offset
开始,从 buffer
渲染 num_frames
个音频帧(每帧 _get_channels 个浮点数)。返回渲染的音频帧数,如果出错则返回 -1。