We are facing an issue with the getInsertionBin() API in our CEP panel for Premiere. Here are the details:
At the beginning, we used to use the API app.project.getInsertionBin() in order to get the target bin to import into. This does not work correctly all the time.
I found no reliable way to set this insertion bin. Intuitively, the currently selected (highlighted) bin in the project should be the insertion bin (this is how it works when importing with Premiere's own menus). That sometimes is the case. But I have found other times that selecting/opening by single/double clicking a bin does not set it as the active insertion bin, as reflected by this API, and as a result, we keep importing to a previously selected bin.
When multiple projects are open at the same time, getInsertionBin() seems to return the same bin even when a different project is active/focused (or when getInsertionBin() is called on a different project object than app.project). This makes imports go into a bin that may not be currently visible to the user. This also proves that Premiere only has one active insertion bin across all projects, not one per project.
I have sometimes seen that import with our panel does not cause any errors, but the import is not reflected in any of the current bins. I think I have seen it when a previously active bin was deleted, or the project of that bin was closed but other projects remained open. This indicates that getInsertionBin() is not always reliable in updating itself to a valid insertion bin when current insertion bin is deleted (or project closed), as perceived by the user.
In order to avoid these issues, we started to use the root of the active project as the import target (project.rootItem). As a result, we do not face any of the above issues, but we lose the ability to import into a separate bin inside a project.
I have tried a third way of trying to identify and keep track of the currently selected bin, by using an event called onSourceClipSelectedInProjectPanel. But this too turned out to be unreliable, since we sometimes get multiple events from Premiere for a single selection change, and those events arrive in random order. For example, if the currently highlighted bin is Bin1 and we now click on Bin2, these random events make our code choose Bin1 or Bin2 randomly, depending on which order the events arrive.
Highly appreciate any help, insight, workarounds etc to get the currently selected bin.