Skip to reading
3D Models & Video in GUIs

23. React when a finite clip finishes

Edition 0.86.4.1 HF1

0.86.4.1 Hotfix 1 edition. Earlier lessons and screenshots retain their original version context; revised references and supplements describe the newer behavior.

Download PDFView PDF page

The typed GUI Events tab has pointer events, not a dedicated On Video Finished action slot. A script can wait for the embedded player’s natural finished signal. Create a Boolean variable clip_done, starting false:

Code example
extends "res://scripts/runtime/script_base.gd"
Code example
func run(_context: Dictionary = {}) -> Variant:
    var player := GetGUIElementProperty(
        "video_lab", "briefing_video", "video_player", null
    ) as VideoStreamPlayer
    if player == null or player.stream == null:
        return false
    await SetVariable({"name": "clip_done", "value": false})
    player.loop = false
    player.paused = false
    player.play()
    await player.finished
    await SetVariable({"name": "clip_done", "value": true})
    return true

Run this from a Play once Button and let the short clip reach its end. You can then place the intended story action after the wait, or test clip_done elsewhere.

Loop is deliberately turned off so the exercise has a natural end. A stop or close is not the same event as reaching that end. If the player can cancel, give the cancel path its own cleanup and result rather than assuming finished ran.

Do not start several copies of the waiting script for one playback. In a finished interface, guard the launch or disable repeated activation while that sequence is active.

Page 33 of 45Permalink
Go to page