Video Stream Player won't receive a signal

Godot 4.2.2

I am trying to get a VideoStreamPlayer to change videos in an array when a signal is received. The signal is received in the main script but is not received in the VideoStreamPlayer script.

I believe the issue is with the VideoStreamPlayer script. I want to figure out a way to either get the stream player to respond to the signal, or to control the stream player from the main script.

The signal is broadcast from the Clyde plug-in dialogue engine.

This is the entire code from the VideoStreamPlayer script:

extends VideoStreamPlayer

@export var videos: Array[VideoStream]
var current_video: int = 0

@onready var dialogue

func _ready(): 
	finished.connect(_play_next)
	_play_next()
	dialogue = ClydeDialogue.new()
	dialogue.load_dialogue("res://steamed_hams.clyde")
	dialogue.event_triggered.connect(on_event_triggered)


func _play_next():
	if current_video >= videos.size():
		return
	stream = videos[current_video]
	play()
	current_video += 1

func on_event_triggered(event_name):
	if event_name == 'show_Hallway':
		print("hallway")
		stream = videos[0]
		play()
	if event_name == 'show_Sitting':
		print("sitting")
		stream = videos[1]
		play()

This is the part of the code that calls the Clyde dialogue in the main script:

func _ready(): 
	#connect scrollbar?
	scrollbar.connect("changed",handle_scrollbar_changed, 1)

	#load dialogue?
	dialogue = ClydeDialogue.new()
	dialogue.load_dialogue("res://steamed_hams.clyde")
	dialogue.start("Dialogue_Start")
	dialogue.connect("event_triggered",Callable(self,'on_event_triggered'))
	dialogue.connect("variable_changed",Callable(self,'on_variable_changed'))

	#how many messages before erasing?
	for n in 30:
		message_spacing()
	
	$MessagesButton.visible = false

This is how I have been trying to control the video player node from the main script. I get an error when I try to use the .play() function since it isn’t defined in the main script’s scope:

func on_event_triggered(event_name):
	if event_name == 'show_Sitting':
		print("sitting")
		$VideoStreamPlayer.stream = videos[1].play()

I am not sure why your signal approach doesn’t work, but in general String based signals are prone to even small typos that are hard to catch, wouldn’t recommend it. Better to use enums, then you’re defining the name only once and you have an always-type-safe-reference ever since.

But the last piece of code with running the method from your main script should work, you’ve just put too much together, I think it should be:
$VideoStreamPlayer.stream = $VideoStreamPlayer.videos[1] $VideoStreamPlayer.play()
Assuming you store your videos array on the video player node.