aboutsummaryrefslogtreecommitdiff
path: root/pages/present.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'pages/present.tsx')
-rw-r--r--pages/present.tsx13
1 files changed, 9 insertions, 4 deletions
diff --git a/pages/present.tsx b/pages/present.tsx
index d1d18a2..085a99c 100644
--- a/pages/present.tsx
+++ b/pages/present.tsx
@@ -22,6 +22,7 @@ export class TimedVideoPlayer {
registeredEventListeners: boolean;
frame: number;
framerate: number;
+ onframe?: (frame: number) => void;
constructor() {
this.slide = -1;
@@ -31,13 +32,13 @@ export class TimedVideoPlayer {
this.registeredEventListeners = false;
}
- frameToTimestampString(frame: number) {
+ frameToTimestampString(frame: number, trim: boolean = true) {
var timecodeString = new Timecode(frame, this.framerate).toString();
- return timecodeString
- .replace(/^(00:)+/, '')
- .replace(';', '.')
+ if (trim) timecodeString = timecodeString.replace(/^(00:)+/, '');
+ timecodeString = timecodeString.replace(';', '.')
.replace(/(:)(\d+?)$/, '.$2')
+ 'f';
+ return timecodeString;
}
timestampToFrame(timestamp: number): number {
@@ -114,8 +115,12 @@ export class TimedVideoPlayer {
setInterval(() => {
if (this.player.paused) return;
+
+ var lastFrame = this.frame;
this.frame = this.timestampToFrame(this.player.currentTime);
+ if (this.frame != lastFrame && this.onframe) this.onframe(this.frame);
+
var slide = this.timeline.slides[this.slide];
if (!slide) return;