Skip to reading
3D Models & Video in GUIs

21. Pause, resume and stop

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 illustrations

Create a separate Pause script record. It obtains the same embedded player and changes its paused flag:

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
    player.paused = true
    return true

Figure 20. The paused frame stays visible. Resume should continue the existing playback rather than restart it.

Assign this record to the Pause Button through run-visual-script and its script ID. A paused player can still report is_playing() as true; paused and stopped are different states.

Page 30 of 45Permalink
Go to page