26. Start playback when the window opens
Autoplay is a construction/configuration request. It is not a new action that runs each time you call Show GUI. Hidden or already constructed elements make an explicit opening sequence easier to reason about.
extends "res://scripts/runtime/script_base.gd"func run(_context: Dictionary = {}) -> Variant:
await ShowGUI({"guiId": "video_lab"})
var player := GetGUIElementProperty(
"video_lab", "briefing_video", "video_player", null
) as VideoStreamPlayer
if player == null or player.stream == null:
return false
player.paused = false
player.play()
return trueAssign this record to the Button or story event that opens the briefing. Keep Autoplay off when this script is responsible for starting it. Decide separately whether the opening HUD should be hidden.
If a particular GUI uses an opening transition, make sure the start time matches the intended presentation. Starting the movie immediately can advance frames while a long transition is still revealing the window.
1. Open the GUI for the first time and check the first visible frame.
2. Close it using the cleanup script.
3. Open it again and confirm the movie restarts because this script calls play.
4. Test a missing stream too; the GUI should still offer its poster/message and a way back.
For deliberate resume-on-open behavior, preserve the paused player and clear paused instead. That is a different design from stopping on close and restarting on open.
