Why can't I seek a VideoPlayer and then pause it?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Fupicat

This script is supposed to seek a VideoPlayer’s stream to a position, then pause it, and tell another node called “Recorder” to take a screenshot and save it to your user folder. After taking the screenshot, this cycle repeats.

But for some reason, this code does nothing, the VideoPlayer’s stream just stays at position 0. Can someone who knows more about VideoPlayer help me out?

extends VideoPlayer

signal im_done

export var recorder_path : NodePath = '../Recorder'

# Get recorder node from path provided by the user.
onready var recorder = get_node(recorder_path)

func _ready():
    var _err = recorder.connect("recording_tick", self, "recording_tick")
    _err = recorder.connect("recording_start", self, "recording_start")
    _err = connect("im_done", recorder, "check_done")

# Called at the beginning of the recording.
func recording_start():

# Called every frame of the recording.
func recording_tick(delta):
    paused = false
    # Jump to the second that equals “current frame number * delta”.
    # Delta = 1 second / X frames per second. Ex: for 60fps, delta = 0.016667
    set_stream_position(recorder.frame * delta)
    # Uncomment this to see: the stream_position is always 0.
    paused = true
    # Tell the recorder your frame is finished.

If you want to test you can download the project file here. Press HOME to start the recording and press END to abort it.

You can run the scene “Tests/AnimationPlayer/AnimationPlayer.tscn” to see a working example of what I’m trying to achieve that uses AnimationPlayers instead of VideoPlayers.