`Constants.SequenceEvent.CLOSED` doesn't seem to fire

SequenceEvent.CLOSED is listed in the Constants reference, but the listener never fires, neither from closing it manually, or with code usingproject.closeSequence()

Code to repro;

// eslint-disable-next-line @typescript-eslint/no-require-imports

const ppro = require("premierepro");

async function init() {
    console.log(ppro.Constants.SequenceEvent);

    ppro.EventManager.addGlobalEventListener(ppro.Constants.SequenceEvent.ACTIVATED, e => console.log("ACTIVATED", e.name, e.id), false);

    ppro.EventManager.addGlobalEventListener(ppro.Constants.SequenceEvent.CLOSED, e => console.log("CLOSED", e), false);

}

init();

/**

* do test

*/

export async function doTest() {

    const project = await ppro.Project.getActiveProject();

    const seq = await project.getActiveSequence();

    await project.closeSequence(seq);

}
doTest();

logs;

ACTIVATED CAMS_01 d3900a77-6886-4021-abe5-be7e7fe53969 ;// initial sequence
;// no close event
ACTIVATED BONUS e50224b7-dacf-4013-8b7a-2c4afaf459e4 ;// sequence that gets activated after the close

I’m not really a programmer and still wrapping my head around typescript so I genuinely do apologise if I’m just missing something here. Please feel free to let me know if that’s the case, or if you require more information.

Premiere Pro 26.5.2, windows 11 - 26H2

Hi @tom_edit ,

I’d suggest one of two ways to address this:

  1. If you have access to the Sequence itself, you can use EventManager.addEventListener() to listen for the CLOSED event directly:
    const project = await ppro.Project.getActiveProject();
    const sequence = await project.getActiveSequence();
    
    ppro.EventManager.addEventListener(
      sequence,
      ppro.Constants.SequenceEvent.CLOSED,
      (event) => { console.log("Sequence closed!"); },
      // useCapture = false,  // the default
    );
    
    We do something like this in our sample panel.
  2. If you want to listen for all CLOSED events regardless of Sequence, use addGlobalEventListener like you have, but switch the useCapture argument to true instead:
    ppro.EventManager.addGlobalEventListener(
      ppro.Constants.SequenceEvent.CLOSED,
      (event) => { console.log(`Sequence ${event.name} was closed!`); },
      true,  // useCapture
    )
    

I’m planning on improving our Event-related documentation in the near future to help clarify better how all of this works. Stay tuned!

2 Likes

Legend, that worked, thanks mate I really appreciate it sorry for the hassle!

2 Likes