You can toggle playback with the TogglePause function on the cinematic sequence device:
# Store a reference to the active sequence so it can be paused
var ActiveSequence : custom_animation_sequence = custom_animation_sequence{}
# An event that signals the active sequence to pause
PauseSequenceEvent : event() = event(){}
OnBegin<override>()<suspends>:void=
# Initialization
# Set the duration of the sequences
for(Sequence : Sequences):
Sequence.SetSequenceTime()
# Loop random sequences
sync:
block:
loop:
if(SequenceToPlay := Sequences[GetRandomInt(0, Sequences.Length - 1)]):
set ActiveSequence = SequenceToPlay
# Play the sequence
ActiveSequence.PlaySequence()
block:
loop:
# Wait for the toggle pause event
PauseSequenceEvent.Await()
# Toggle the playback of the sequence
ActiveSequence.CinematicSequenceDevice.TogglePause()
If you wanted to cancel the playback you could do something similar with a race condition and GoToEndAndStop.