UXP for Premiere - findItemsMatchingMediaPath Function
I’m currently migrating a panel built with CEP to UXP, and I’ve run into an issue with a specific function.
In CEP, there is a function called ProjectItem.findItemsMatchingMediaPath().
I used it directly from the root item like this:
var matchedItems = app.project.rootItem.findItemsMatchingMediaPath(path, true); This allowed me to search the entire project tree from the root and return all items whose mediaPath matched.
However, in UXP, this function appears to be available only on ClipProjectItem.
I attempted to cast it as follows, but it does not work:
const ppro = require(‘premierepro’);
const activeProject = await ppro.Project.getActiveProject();
const rootItem = await activeProject.getRootItem(); // is FolderItem
const rootProjectItem = await ppro.ProjectItem.cast(rootItem); // is ProjectItem
const rootClipProjectItem = await ppro.ClipProjectItem.cast(rootProjectItem); // is null
Is this behavior intended?
If so, it seems the only option is to traverse the entire root tree manually to find matching items.
In the sample code below, it looks like items are retrieved from the root and searched manually:
Does this mean we are expected to implement our own version of findItemsMatchingMediaPath in UXP using this approach?
If that’s the case, I’m concerned about performance.
When there are many files, this manual traversal could be significantly slower compared to CEP’s built-in function:
var matchedItems = app.project.rootItem.findItemsMatchingMediaPath(path, true);
Is there any way in UXP to process this in a single step similar to CEP, or an alternative API that provides equivalent performance?
