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.

VideoStreamPlayer

繼承: Control < CanvasItem < Node < Object

用於播放影片的控制項。

說明

A control used for playback of VideoStream resources.

Supported video formats are Ogg Theora (.ogv, VideoStreamTheora) and any format exposed via a GDExtension plugin.

Warning: On Web, video playback will perform poorly due to missing architecture-specific assembly optimizations.

教學

屬性

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

The stream's current speed scale. 1.0 is the normal speed, while 2.0 is double speed and 0.5 is half speed. A speed scale of 0.0 pauses the video, similar to setting paused to true.


VideoStream stream 🔗

指定的影片流。支援的格式見描述。


float stream_position 🔗

  • void set_stream_position(value: float)

  • float get_stream_position()

The current position of the stream, in seconds.


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 🔗

The length of the current stream, in seconds.


String get_stream_name() const 🔗

返回影片流的名稱,如果沒有指定影片流,則返回 "<No Stream>"


Texture2D get_video_texture() const 🔗

將目前影格作為 Texture2D 返回。


bool is_playing() const 🔗

如果影片正在播放,返回 true

注意:如果在播放過程中暫停,影片仍被認為在播放。


void play() 🔗

從頭開始播放影片。如果影片處於暫停狀態,不會取消暫停。


void stop() 🔗

停止影片播放並將影片流位置設定為 0。

注意:雖然影片流位置將被設定為 0,但影片流的第一影格不會成為目前影格。