Skip to content

Commit fe4d327

Browse files
committed
Include duration in previews
1 parent fd5c10a commit fe4d327

File tree

6 files changed

+19
-17
lines changed

6 files changed

+19
-17
lines changed

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import VideomailClient from "./client";
2-
import { Command, CommandArgs } from "./types/command";
2+
import { Command, VideomailCommandArgs } from "./types/command";
33
import DeliveryRecord from "./types/DeliveryRecord";
44
import { EmailAddress, EmailAddresses } from "./types/EmailAddress";
55
import { FullVideomailErrorData, VideomailErrorData } from "./types/error";
@@ -11,7 +11,6 @@ import { VideoType, VideoTypeType } from "./types/VideoType";
1111

1212
export type {
1313
Command,
14-
CommandArgs,
1514
DeliveryRecord,
1615
EmailAddress,
1716
EmailAddresses,
@@ -20,6 +19,7 @@ export type {
2019
RecordingStats,
2120
Videomail,
2221
VideomailClientOptions,
22+
VideomailCommandArgs,
2323
VideomailErrorData,
2424
VideomailEvents,
2525
VideoTypeType,

src/types/command.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@ import { ErrorObject } from "serialize-error";
22

33
// Do not trust what we receive from server side.
44
// Therefore, all of them can be undefined and require additional checks
5-
export interface CommandArgs {
5+
export interface VideomailCommandArgs {
66
frame?: number;
77
key?: string | undefined;
88
err?: ErrorObject;
99
sample?: number;
1010
mp4?: string;
1111
webm?: string;
12+
duration?: number;
1213
}
1314

1415
export interface Command {
1516
command: string;
16-
args?: CommandArgs;
17+
args?: VideomailCommandArgs;
1718
}

src/types/events/index.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@ export interface ProgressParams {
2929
sampleProgress?: string | undefined;
3030
}
3131

32-
export interface PreviewParams {
32+
export interface VideomailPreviewParams {
3333
key?: string | undefined;
34-
width?: number | undefined;
35-
height?: number | undefined;
34+
width: number | undefined;
35+
height: number | undefined;
3636
hasAudio: boolean;
37+
duration: number;
3738
}
3839

3940
export interface StoppedParams {
@@ -103,7 +104,7 @@ interface VideomailEvents {
103104
// recording is being paused
104105
PAUSED: () => void;
105106
// video preview is set
106-
PREVIEW: (params?: PreviewParams) => void;
107+
PREVIEW: (params?: VideomailPreviewParams) => void;
107108
// video preview is shown
108109
PREVIEW_SHOWN: () => void;
109110
// start sending

src/wrappers/form.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import getFormData from "get-form-data";
22

3-
import { ErrorParams, PreviewParams } from "../types/events";
3+
import { ErrorParams, VideomailPreviewParams } from "../types/events";
44
import { VideomailClientOptions } from "../types/options";
55
import Videomail, { PartialVideomail } from "../types/Videomail";
66
import Despot from "../util/Despot";
@@ -243,7 +243,7 @@ class Form extends Despot {
243243
}
244244
}
245245

246-
this.on("PREVIEW", (params?: PreviewParams) => {
246+
this.on("PREVIEW", (params?: VideomailPreviewParams) => {
247247
/*
248248
* Beware that preview doesn't always come with a key, i.E.
249249
* container.show() can emit PREVIEW without a key when a replay already exists

src/wrappers/visuals/recorder.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { deserializeError } from "serialize-error";
55
import websocket from "websocket-stream";
66

77
import Constants from "../../constants";
8-
import { Command, CommandArgs } from "../../types/command";
8+
import { Command, VideomailCommandArgs } from "../../types/command";
99
import { UserMediaReadyParams } from "../../types/events";
1010
import { VideomailClientOptions } from "../../types/options";
1111
import RecordingStats from "../../types/RecordingStats";
@@ -248,7 +248,7 @@ class Recorder extends Despot {
248248
});
249249
}
250250

251-
private updateFrameProgress(args?: CommandArgs) {
251+
private updateFrameProgress(args?: VideomailCommandArgs) {
252252
if (!args) {
253253
throw createError({
254254
message: "Arguments are missing for updating the frame progress",
@@ -268,7 +268,7 @@ class Recorder extends Despot {
268268
this.updateOverallProgress();
269269
}
270270

271-
private updateSampleProgress(args?: CommandArgs) {
271+
private updateSampleProgress(args?: VideomailCommandArgs) {
272272
if (!args) {
273273
throw createError({
274274
message: "Arguments are missing for updating the audio sample progress",
@@ -288,7 +288,7 @@ class Recorder extends Despot {
288288
this.updateOverallProgress();
289289
}
290290

291-
private preview(args?: CommandArgs) {
291+
private preview(args?: VideomailCommandArgs) {
292292
if (!args) {
293293
throw createError({
294294
message: "Preview arguments are missing.",
@@ -331,7 +331,7 @@ class Recorder extends Despot {
331331
const width = this.getRecorderWidth(true);
332332
const height = this.getRecorderHeight(true);
333333

334-
this.emit("PREVIEW", { key: this.key, width, height, hasAudio });
334+
this.emit("PREVIEW", { key: this.key, width, height, hasAudio, duration: -1 });
335335

336336
// keep it for recording stats
337337
if (this.stopTime) {

src/wrappers/visuals/replay.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PreviewParams } from "../../types/events";
1+
import { VideomailPreviewParams } from "../../types/events";
22
import { VideomailClientOptions } from "../../types/options";
33
import Videomail from "../../types/Videomail";
44
import { VideoType } from "../../types/VideoType";
@@ -263,7 +263,7 @@ class Replay extends Despot {
263263

264264
if (!this.built) {
265265
if (!this.isStandalone()) {
266-
this.on("PREVIEW", (params?: PreviewParams) => {
266+
this.on("PREVIEW", (params?: VideomailPreviewParams) => {
267267
this.show(params?.width, params?.height, params?.hasAudio);
268268
});
269269
}

0 commit comments

Comments
 (0)