Checking trackItem clip Selection status - UXP

Hi,
I would like to know how to access the properties of a clip in a video track—specifically, its name, its IN and OUT points, and whether it is selected or not. Is it possible to achieve this with code similar to the following?

Thanks in advance! :blush:

const activeProject = await ppro.Project.getActiveProject();
const activeSequence = await activeProject.getActiveSequence();
const videoTrackCount = await activeSequence.getVideoTrackCount();

for (let i = 0; i < videoTrackCount; i++) {
    const videoTrack = await activeSequence.getVideoTrack(i);
    const trackItems = await videoTrack.getTrackItems(1, false);
    for (let t=0; t < trackItems.length; t++){
        console.log(trackItems[t]);
        //How to know if this clip item is selected?
        //Its name?
        //Its in and out points?
    }
}
1 Like

Hi!

You can access following properties by:

const activeProject = await ppro.Project.getActiveProject();
const activeSequence = await activeProject.getActiveSequence();
const videoTrackCount = await activeSequence.getVideoTrackCount();

for (let i = 0; i < videoTrackCount; i++) {
    const videoTrack = await activeSequence.getVideoTrack(i);
    const trackItems = await videoTrack.getTrackItems(1, false);
    for (let t=0; t < trackItems.length; t++){
        console.log(trackItems[t]);
        //How to know if this clip item is selected?
        //**We are still working on API which return list of selected *trackItems* in the active sequence.**         
        //**However, if you are interested in if the associated *clip* of the *trackItem* is being selected at the project panel, following code will help.** 
        let projectItem = await trackItems[t].getProjectItem(); 
        const projectSelection = await ppro.ProjectUtils.getSelection(activeProject);
        const projectItems = await projectSelection.getItems();
        let selected = false;
        for (const currItem of projectItems){
          if (currItem == projectItem){
            selected = true;
          }
        }
        //Its name?
        let name = await projectItem.name;
        //It's in and out points?
        let inPoint = await trackItems[t].getInPoint();
        let outpoint = await trackItems[t].getOutPoint()
    }
}

Thanks for trying out UXP!

3 Likes
export declare type VideoClipTrackItem = {
  createAddVideoTransitionAction(
    videoTransition: VideoTransition,
    addTransitionOptionsProperties?: AddTransitionOptions
  ): Action; //Create add transition action for sequence
  createRemoveVideoTransitionAction(transitionPosition?: number): Action; //Returns true if trackItem has transition
  getMatchName(): Promise<string>; //Returns the value of internal matchname for this trackItem
  getSpeed(): Promise<number>; //Returns the value of speed of the trackItem
  isAdjustmentLayer(): Promise<boolean>; //Returns true if the trackitem is an adjustment layer
  isSpeedReversed(): Promise<number>; //Returns true if the trackitem is reversed
  createMoveAction(tickTime: TickTime): Action; //Returns an action moves the inPoint of the track item to a new time, by shifting it by a number of seconds.
  getInPoint(): Promise<TickTime>; //Get timecode representing the inPoint of sequence.
  getOutPoint(): Promise<TickTime>; //Get timecode representing the outPoint of sequence.
  createSetInPointAction(tickTime: TickTime): Action; //Create SetInPointAction for sequence
  createSetOutPointAction(tickTime: TickTime): Action; //Create SetInPointAction for sequence
  getStartTime(): Promise<TickTime>; //Timecode representing the start of this track item relative to the sequence start.
  getEndTime(): Promise<TickTime>; //Timecode representing the end of this track item relative to the sequence start.
  getDuration(): Promise<TickTime>; //Timecode representing the duration of this track item relative to the sequence start.
  getType(): Promise<number>; //Index representing the type of this track item.
  isDisabled(): Promise<boolean>; //Returns true if rackitem is muted/disabled
  createSetDisabledAction(disabled: boolean): Action; //Returns an action that enables/disables the trackItem
  getMediaType(): Promise<Guid>; //UUID representing the underlying media type of this track item
  getTrackIndex(): Promise<number>; //Index representing the track index of the track this track item belongs to
  getProjectItem(): Promise<ProjectItem>; //The project item for this track item.
  getComponentChain(): Promise<VideoComponentChain>; //Returns VideoComponentChain
};

haha,no name

1 Like

Hi again kernelKun,

Getting and setting trackItem names will also be available in the next SDK pre-release.

2 Likes

Thank you very much for your reply, CathyDong. What I need to know about the clip isn’t its own IN and OUT points, but rather its IN and OUT points within the sequence — that is, the clip’s position in the sequence’s timecode.

Thank you very much for the information, kernelKun, and sorry for the delay in replying.
I’ll give it a try and see if it works.