VideoStreamPlayer

继承: Control < CanvasItem < Node < Object

用于播放视频的控件。

描述

用于播放 VideoStream 资源的控件。

支持的视频格式有 Ogg Theora.ogvVideoStreamTheora)以及任何通过 GDExtension 插件公开的格式。

警告:在 Web 上,视频播放由于缺少特定于体系结构的汇编优化而表现不佳。

教程

属性

int

audio_track

0

bool

autoplay

false

int

buffering_msec

500

StringName

bus

&"Master"

bool

expand

false

bool

loop

false

bool

paused

false

float

speed_scale

1.0

VideoStream

stream

float

stream_position

float

volume

float

volume_db

0.0

方法

float

get_stream_length() const

String

get_stream_name() const

Texture2D

get_video_texture() const

bool

is_playing() const

void

play()

void

stop()


信号

finished() 🔗

播放结束时触发。


属性说明

int audio_track = 0 🔗

  • void set_audio_track(value: int)

  • int get_audio_track()

要播放的嵌入式音轨。


bool autoplay = false 🔗

  • void set_autoplay(value: bool)

  • bool has_autoplay()

如果为 true,当场景加载时开始播放。


int buffering_msec = 500 🔗

  • void set_buffering_msec(value: int)

  • int get_buffering_msec()

播放时存储在缓冲区的时间,以毫秒计。


StringName bus = &"Master" 🔗

用于声音播放的音频总线。


bool expand = false 🔗

  • void set_expand(value: bool)

  • bool has_expand()

如果为 true,视频会缩放到控件的尺寸。否则,控件的最小尺寸将被自动调整以匹配视频流的尺寸。


bool loop = false 🔗

  • void set_loop(value: bool)

  • bool has_loop()

如果为 true,该视频将在到达末尾时重新开始。


bool paused = false 🔗

  • void set_paused(value: bool)

  • bool is_paused()

如果为 true,则暂停视频。


float speed_scale = 1.0 🔗

  • void set_speed_scale(value: float)

  • float get_speed_scale()

视频流的当前速度缩放。1.0 是正常速度,2.0 是二倍速,0.5 是半速。速度缩放为 0.0 会暂停视频,类似于将 paused 设置为 true


VideoStream stream 🔗

指定的视频流。支持的格式见描述。


float stream_position 🔗

  • void set_stream_position(value: float)

  • float get_stream_position()

返回视频流中的当前位置,单位为秒。


float volume 🔗

  • void set_volume(value: float)

  • float get_volume()

音频音量为线性值。


float volume_db = 0.0 🔗

  • void set_volume_db(value: float)

  • float get_volume_db()

音频音量,单位是 dB。


方法说明

float get_stream_length() const 🔗

当前视频流的长度,单位为秒。


String get_stream_name() const 🔗

返回视频流的名称,如果没有指定视频流,则返回 "<No Stream>"


Texture2D get_video_texture() const 🔗

将当前帧作为 Texture2D 返回。


bool is_playing() const 🔗

如果视频正在播放,返回 true

注意:如果在播放过程中暂停,视频仍被认为在播放。


void play() 🔗

从头开始播放视频。如果视频处于暂停状态,不会取消暂停。


void stop() 🔗

停止视频播放并将视频流位置设置为 0。

注意:虽然视频流位置将被设置为 0,但视频流的第一帧不会成为当前帧。