Skip to content
This repository has been archived by the owner on Dec 7, 2021. It is now read-only.

feat: Shortcut keys for Next/Previous Visited Frame #904

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ When the video playback bar is present, it allows the following shortcuts to sel
* D or ArrowRight - Next Frame
* Q - Previous Tagged Frame
* E - Next Tagged Frame
* H - Previous Visited Frame
* L - Next Visited Frame

#### Mouse Controls

Expand Down
6 changes: 6 additions & 0 deletions src/common/localization/en-us.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,12 @@ export const english: IAppStrings = {
nextTaggedFrame: {
tooltip: "Next Tagged Frame",
},
previousVisitedFrame: {
tooltip: "Previous Visited Frame",
},
nextVisitedFrame: {
tooltip: "Next Visited Frame",
},
previousExpectedFrame: {
tooltip: "Previous Frame",
},
Expand Down
6 changes: 6 additions & 0 deletions src/common/localization/es-cl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,12 @@ export const spanish: IAppStrings = {
nextTaggedFrame: {
tooltip: "Siguiente marco etiquetado",
},
previousVisitedFrame: {
tooltip: "Fotograma visitado anterior",
},
nextVisitedFrame: {
tooltip: "Siguiente marco visitado",
},
previousExpectedFrame: {
tooltip: "Fotograma anterior",
},
Expand Down
6 changes: 6 additions & 0 deletions src/common/strings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,12 @@ export interface IAppStrings {
previousExpectedFrame: {
tooltip: string,
},
nextVisitedFrame: {
tooltip: string,
},
previousVisitedFrame: {
tooltip: string,
},
}
help: {
title: string;
Expand Down
44 changes: 44 additions & 0 deletions src/react/components/common/assetPreview/videoAsset.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { IAssetProps } from "./assetPreview";
import { IAsset, AssetType, AssetState } from "../../../../models/applicationState";
import { AssetService } from "../../../../services/assetService";
import { CustomVideoPlayerButton } from "../../common/videoPlayer/customVideoPlayerButton";
import { CustomVideoPlayerKeyBinding } from "../../common/videoPlayer/customVideoPlayerButton";
import { strings } from "../../../../common/strings";

/**
Expand Down Expand Up @@ -119,6 +120,20 @@ export class VideoAsset extends React.Component<IVideoAssetProps> {
>
<i className="fas fa-step-forward"></i>
</CustomVideoPlayerButton>
<CustomVideoPlayerKeyBinding order={8.3}
accelerators={["H", "h"]}
tooltip={strings.editorPage.videoPlayer.previousVisitedFrame.tooltip}
onClick={this.movePreviousVisitedFrame}
icon={"fas fa-step-backward"}
>
</CustomVideoPlayerKeyBinding>
<CustomVideoPlayerKeyBinding order={8.4}
accelerators={["L", "l"]}
tooltip={strings.editorPage.videoPlayer.nextVisitedFrame.tooltip}
onClick={this.moveNextVisitedFrame}
icon={"fas fa-step-forward"}
>
</CustomVideoPlayerKeyBinding>
</ControlBar>
}
</Player >
Expand Down Expand Up @@ -177,6 +192,35 @@ export class VideoAsset extends React.Component<IVideoAssetProps> {
}
}

/**
* Bound to the "Previous Visited Frame" button
* Seeks the user to the previous visited video frame
*/
private movePreviousVisitedFrame = () => {
const currentTime = this.getVideoPlayerState().currentTime;
const previousFrame = _
.reverse(this.props.childAssets)
.find((asset) => asset.state === AssetState.Visited && asset.timestamp < currentTime);

if (previousFrame) {
this.seekToTime(previousFrame.timestamp);
}
}

/**
* Bound to the "Next Visited Frame" button
* Seeks the user to the next visited video frame
*/
private moveNextVisitedFrame = () => {
const currentTime = this.getVideoPlayerState().currentTime;
const nextFrame = this.props.childAssets
.find((asset) => asset.state === AssetState.Visited && asset.timestamp > currentTime);

if (nextFrame) {
this.seekToTime(nextFrame.timestamp);
}
}

/**
* Moves the videos current position forward one frame based on the current
* project settings for frame rate extraction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,19 @@ export class CustomVideoPlayerButton extends React.Component<ICustomVideoPlayerB
);
}
}

export class CustomVideoPlayerKeyBinding extends React.Component<ICustomVideoPlayerButtonProps> {
public render() {
return (
<Fragment>
{this.props.accelerators &&
<KeyboardBinding keyEventType={KeyEventType.KeyDown}
displayName={this.props.tooltip}
accelerators={this.props.accelerators}
handler={this.props.onClick}
icon={this.props.icon}/>
}
</Fragment>
);
}
}