@lookit/record 1.0.0 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +87 -85
- package/dist/index.browser.js +9082 -9918
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.min.js +50 -2
- package/dist/index.browser.min.js.map +1 -1
- package/dist/index.cjs +854 -10006
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +760 -6
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +854 -10006
- package/dist/index.js.map +1 -1
- package/package.json +8 -13
- package/src/index.spec.ts +6 -2
- package/src/index.ts +1 -1
- package/src/recorder.spec.ts +1 -1
- package/src/stop.ts +11 -6
- package/src/{video_config.spec.ts → videoConfig.spec.ts} +70 -85
- package/src/{video_config.ts → videoConfig.ts} +70 -72
- package/src/{video_config_mic_check.spec.ts → videoConfig_mic_check.spec.ts} +1 -1
- package/dist/consentVideo.d.ts +0 -370
- package/dist/errors.d.ts +0 -149
- package/dist/mic_check.d.ts +0 -33
- package/dist/recorder.d.ts +0 -158
- package/dist/start.d.ts +0 -24
- package/dist/stop.d.ts +0 -30
- package/dist/trial.d.ts +0 -36
- package/dist/types.d.ts +0 -10
- package/dist/video_config.d.ts +0 -296
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,760 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { JsPsychPlugin, ParameterType, JsPsych, TrialType, JsPsychExtension, JsPsychExtensionInfo } from 'jspsych';
|
|
2
|
+
|
|
3
|
+
declare const info$3: {
|
|
4
|
+
readonly name: "consent-video";
|
|
5
|
+
readonly version: string;
|
|
6
|
+
readonly parameters: {
|
|
7
|
+
readonly template: {
|
|
8
|
+
readonly type: ParameterType.STRING;
|
|
9
|
+
readonly default: "consent-template-5";
|
|
10
|
+
};
|
|
11
|
+
readonly locale: {
|
|
12
|
+
readonly type: ParameterType.STRING;
|
|
13
|
+
readonly default: "en-us";
|
|
14
|
+
};
|
|
15
|
+
readonly additional_video_privacy_statement: {
|
|
16
|
+
readonly type: ParameterType.STRING;
|
|
17
|
+
readonly default: "";
|
|
18
|
+
};
|
|
19
|
+
readonly datause: {
|
|
20
|
+
readonly type: ParameterType.STRING;
|
|
21
|
+
readonly default: "";
|
|
22
|
+
};
|
|
23
|
+
readonly gdpr: {
|
|
24
|
+
readonly type: ParameterType.BOOL;
|
|
25
|
+
readonly default: false;
|
|
26
|
+
};
|
|
27
|
+
readonly gdpr_personal_data: {
|
|
28
|
+
readonly type: ParameterType.STRING;
|
|
29
|
+
readonly default: "";
|
|
30
|
+
};
|
|
31
|
+
readonly gdpr_sensitive_data: {
|
|
32
|
+
readonly type: ParameterType.STRING;
|
|
33
|
+
readonly default: "";
|
|
34
|
+
};
|
|
35
|
+
readonly PIName: {
|
|
36
|
+
readonly type: ParameterType.STRING;
|
|
37
|
+
readonly default: undefined;
|
|
38
|
+
};
|
|
39
|
+
readonly include_databrary: {
|
|
40
|
+
readonly type: ParameterType.BOOL;
|
|
41
|
+
readonly default: false;
|
|
42
|
+
};
|
|
43
|
+
readonly institution: {
|
|
44
|
+
readonly type: ParameterType.STRING;
|
|
45
|
+
readonly default: undefined;
|
|
46
|
+
};
|
|
47
|
+
readonly PIContact: {
|
|
48
|
+
readonly type: ParameterType.STRING;
|
|
49
|
+
readonly default: undefined;
|
|
50
|
+
};
|
|
51
|
+
readonly payment: {
|
|
52
|
+
readonly type: ParameterType.STRING;
|
|
53
|
+
readonly default: undefined;
|
|
54
|
+
};
|
|
55
|
+
readonly private_level_only: {
|
|
56
|
+
readonly type: ParameterType.BOOL;
|
|
57
|
+
readonly default: false;
|
|
58
|
+
};
|
|
59
|
+
readonly procedures: {
|
|
60
|
+
readonly type: ParameterType.STRING;
|
|
61
|
+
readonly default: undefined;
|
|
62
|
+
};
|
|
63
|
+
readonly purpose: {
|
|
64
|
+
readonly type: ParameterType.STRING;
|
|
65
|
+
readonly default: undefined;
|
|
66
|
+
};
|
|
67
|
+
readonly research_rights_statement: {
|
|
68
|
+
readonly type: ParameterType.STRING;
|
|
69
|
+
readonly default: "";
|
|
70
|
+
};
|
|
71
|
+
readonly risk_statement: {
|
|
72
|
+
readonly type: ParameterType.STRING;
|
|
73
|
+
readonly default: "";
|
|
74
|
+
};
|
|
75
|
+
readonly voluntary_participation: {
|
|
76
|
+
readonly type: ParameterType.STRING;
|
|
77
|
+
readonly default: "";
|
|
78
|
+
};
|
|
79
|
+
readonly purpose_header: {
|
|
80
|
+
readonly type: ParameterType.STRING;
|
|
81
|
+
readonly default: "";
|
|
82
|
+
};
|
|
83
|
+
readonly procedures_header: {
|
|
84
|
+
readonly type: ParameterType.STRING;
|
|
85
|
+
readonly default: "";
|
|
86
|
+
};
|
|
87
|
+
readonly participation_header: {
|
|
88
|
+
readonly type: ParameterType.STRING;
|
|
89
|
+
readonly default: "";
|
|
90
|
+
};
|
|
91
|
+
readonly benefits_header: {
|
|
92
|
+
readonly type: ParameterType.STRING;
|
|
93
|
+
readonly default: "";
|
|
94
|
+
};
|
|
95
|
+
readonly risk_header: {
|
|
96
|
+
readonly type: ParameterType.STRING;
|
|
97
|
+
readonly default: "";
|
|
98
|
+
};
|
|
99
|
+
readonly summary_statement: {
|
|
100
|
+
readonly type: ParameterType.STRING;
|
|
101
|
+
readonly default: "";
|
|
102
|
+
};
|
|
103
|
+
readonly additional_segments: {
|
|
104
|
+
readonly type: ParameterType.COMPLEX;
|
|
105
|
+
readonly array: true;
|
|
106
|
+
readonly default: readonly [];
|
|
107
|
+
readonly nested: {
|
|
108
|
+
readonly title: {
|
|
109
|
+
readonly type: ParameterType.STRING;
|
|
110
|
+
readonly default: "";
|
|
111
|
+
};
|
|
112
|
+
readonly text: {
|
|
113
|
+
readonly type: ParameterType.STRING;
|
|
114
|
+
readonly default: "";
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
};
|
|
118
|
+
readonly prompt_all_adults: {
|
|
119
|
+
readonly type: ParameterType.BOOL;
|
|
120
|
+
readonly default: false;
|
|
121
|
+
};
|
|
122
|
+
readonly prompt_only_adults: {
|
|
123
|
+
readonly type: ParameterType.BOOL;
|
|
124
|
+
readonly default: false;
|
|
125
|
+
};
|
|
126
|
+
readonly consent_statement_text: {
|
|
127
|
+
readonly type: ParameterType.STRING;
|
|
128
|
+
readonly default: "";
|
|
129
|
+
};
|
|
130
|
+
readonly omit_injury_phrase: {
|
|
131
|
+
readonly type: ParameterType.BOOL;
|
|
132
|
+
readonly default: false;
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
};
|
|
136
|
+
type Info$3 = typeof info$3;
|
|
137
|
+
/** The video consent plugin. */
|
|
138
|
+
declare class VideoConsentPlugin implements JsPsychPlugin<Info$3> {
|
|
139
|
+
private readonly jsPsych;
|
|
140
|
+
static readonly info: {
|
|
141
|
+
readonly name: "consent-video";
|
|
142
|
+
readonly version: string;
|
|
143
|
+
readonly parameters: {
|
|
144
|
+
readonly template: {
|
|
145
|
+
readonly type: ParameterType.STRING;
|
|
146
|
+
readonly default: "consent-template-5";
|
|
147
|
+
};
|
|
148
|
+
readonly locale: {
|
|
149
|
+
readonly type: ParameterType.STRING;
|
|
150
|
+
readonly default: "en-us";
|
|
151
|
+
};
|
|
152
|
+
readonly additional_video_privacy_statement: {
|
|
153
|
+
readonly type: ParameterType.STRING;
|
|
154
|
+
readonly default: "";
|
|
155
|
+
};
|
|
156
|
+
readonly datause: {
|
|
157
|
+
readonly type: ParameterType.STRING;
|
|
158
|
+
readonly default: "";
|
|
159
|
+
};
|
|
160
|
+
readonly gdpr: {
|
|
161
|
+
readonly type: ParameterType.BOOL;
|
|
162
|
+
readonly default: false;
|
|
163
|
+
};
|
|
164
|
+
readonly gdpr_personal_data: {
|
|
165
|
+
readonly type: ParameterType.STRING;
|
|
166
|
+
readonly default: "";
|
|
167
|
+
};
|
|
168
|
+
readonly gdpr_sensitive_data: {
|
|
169
|
+
readonly type: ParameterType.STRING;
|
|
170
|
+
readonly default: "";
|
|
171
|
+
};
|
|
172
|
+
readonly PIName: {
|
|
173
|
+
readonly type: ParameterType.STRING;
|
|
174
|
+
readonly default: undefined;
|
|
175
|
+
};
|
|
176
|
+
readonly include_databrary: {
|
|
177
|
+
readonly type: ParameterType.BOOL;
|
|
178
|
+
readonly default: false;
|
|
179
|
+
};
|
|
180
|
+
readonly institution: {
|
|
181
|
+
readonly type: ParameterType.STRING;
|
|
182
|
+
readonly default: undefined;
|
|
183
|
+
};
|
|
184
|
+
readonly PIContact: {
|
|
185
|
+
readonly type: ParameterType.STRING;
|
|
186
|
+
readonly default: undefined;
|
|
187
|
+
};
|
|
188
|
+
readonly payment: {
|
|
189
|
+
readonly type: ParameterType.STRING;
|
|
190
|
+
readonly default: undefined;
|
|
191
|
+
};
|
|
192
|
+
readonly private_level_only: {
|
|
193
|
+
readonly type: ParameterType.BOOL;
|
|
194
|
+
readonly default: false;
|
|
195
|
+
};
|
|
196
|
+
readonly procedures: {
|
|
197
|
+
readonly type: ParameterType.STRING;
|
|
198
|
+
readonly default: undefined;
|
|
199
|
+
};
|
|
200
|
+
readonly purpose: {
|
|
201
|
+
readonly type: ParameterType.STRING;
|
|
202
|
+
readonly default: undefined;
|
|
203
|
+
};
|
|
204
|
+
readonly research_rights_statement: {
|
|
205
|
+
readonly type: ParameterType.STRING;
|
|
206
|
+
readonly default: "";
|
|
207
|
+
};
|
|
208
|
+
readonly risk_statement: {
|
|
209
|
+
readonly type: ParameterType.STRING;
|
|
210
|
+
readonly default: "";
|
|
211
|
+
};
|
|
212
|
+
readonly voluntary_participation: {
|
|
213
|
+
readonly type: ParameterType.STRING;
|
|
214
|
+
readonly default: "";
|
|
215
|
+
};
|
|
216
|
+
readonly purpose_header: {
|
|
217
|
+
readonly type: ParameterType.STRING;
|
|
218
|
+
readonly default: "";
|
|
219
|
+
};
|
|
220
|
+
readonly procedures_header: {
|
|
221
|
+
readonly type: ParameterType.STRING;
|
|
222
|
+
readonly default: "";
|
|
223
|
+
};
|
|
224
|
+
readonly participation_header: {
|
|
225
|
+
readonly type: ParameterType.STRING;
|
|
226
|
+
readonly default: "";
|
|
227
|
+
};
|
|
228
|
+
readonly benefits_header: {
|
|
229
|
+
readonly type: ParameterType.STRING;
|
|
230
|
+
readonly default: "";
|
|
231
|
+
};
|
|
232
|
+
readonly risk_header: {
|
|
233
|
+
readonly type: ParameterType.STRING;
|
|
234
|
+
readonly default: "";
|
|
235
|
+
};
|
|
236
|
+
readonly summary_statement: {
|
|
237
|
+
readonly type: ParameterType.STRING;
|
|
238
|
+
readonly default: "";
|
|
239
|
+
};
|
|
240
|
+
readonly additional_segments: {
|
|
241
|
+
readonly type: ParameterType.COMPLEX;
|
|
242
|
+
readonly array: true;
|
|
243
|
+
readonly default: readonly [];
|
|
244
|
+
readonly nested: {
|
|
245
|
+
readonly title: {
|
|
246
|
+
readonly type: ParameterType.STRING;
|
|
247
|
+
readonly default: "";
|
|
248
|
+
};
|
|
249
|
+
readonly text: {
|
|
250
|
+
readonly type: ParameterType.STRING;
|
|
251
|
+
readonly default: "";
|
|
252
|
+
};
|
|
253
|
+
};
|
|
254
|
+
};
|
|
255
|
+
readonly prompt_all_adults: {
|
|
256
|
+
readonly type: ParameterType.BOOL;
|
|
257
|
+
readonly default: false;
|
|
258
|
+
};
|
|
259
|
+
readonly prompt_only_adults: {
|
|
260
|
+
readonly type: ParameterType.BOOL;
|
|
261
|
+
readonly default: false;
|
|
262
|
+
};
|
|
263
|
+
readonly consent_statement_text: {
|
|
264
|
+
readonly type: ParameterType.STRING;
|
|
265
|
+
readonly default: "";
|
|
266
|
+
};
|
|
267
|
+
readonly omit_injury_phrase: {
|
|
268
|
+
readonly type: ParameterType.BOOL;
|
|
269
|
+
readonly default: false;
|
|
270
|
+
};
|
|
271
|
+
};
|
|
272
|
+
};
|
|
273
|
+
private readonly recorder;
|
|
274
|
+
private readonly video_container_id;
|
|
275
|
+
/**
|
|
276
|
+
* Instantiate video consent plugin.
|
|
277
|
+
*
|
|
278
|
+
* @param jsPsych - JsPsych object
|
|
279
|
+
*/
|
|
280
|
+
constructor(jsPsych: JsPsych);
|
|
281
|
+
/**
|
|
282
|
+
* Create/Show trial view.
|
|
283
|
+
*
|
|
284
|
+
* @param display - HTML element for experiment.
|
|
285
|
+
* @param trial - Trial data including user supplied parameters.
|
|
286
|
+
*/
|
|
287
|
+
trial(display: HTMLElement, trial: TrialType<Info$3>): void;
|
|
288
|
+
/**
|
|
289
|
+
* Retrieve video container element.
|
|
290
|
+
*
|
|
291
|
+
* @param display - HTML element for experiment.
|
|
292
|
+
* @returns Video container
|
|
293
|
+
*/
|
|
294
|
+
private getVideoContainer;
|
|
295
|
+
/**
|
|
296
|
+
* Add webcam feed to HTML.
|
|
297
|
+
*
|
|
298
|
+
* @param display - HTML element for experiment.
|
|
299
|
+
*/
|
|
300
|
+
private recordFeed;
|
|
301
|
+
/**
|
|
302
|
+
* Playback Feed
|
|
303
|
+
*
|
|
304
|
+
* @param display - JsPsych display HTML element.
|
|
305
|
+
*/
|
|
306
|
+
private playbackFeed;
|
|
307
|
+
/**
|
|
308
|
+
* Put back the webcam feed once the video recording has ended. This is used
|
|
309
|
+
* with the "ended" Event.
|
|
310
|
+
*
|
|
311
|
+
* @param display - JsPsych display HTML element.
|
|
312
|
+
* @returns Event function
|
|
313
|
+
*/
|
|
314
|
+
private onEnded;
|
|
315
|
+
/**
|
|
316
|
+
* Retrieve button element from DOM.
|
|
317
|
+
*
|
|
318
|
+
* @param display - HTML element for experiment.
|
|
319
|
+
* @param id - Element id
|
|
320
|
+
* @returns Button element
|
|
321
|
+
*/
|
|
322
|
+
private getButton;
|
|
323
|
+
/**
|
|
324
|
+
* Select and return the image element.
|
|
325
|
+
*
|
|
326
|
+
* @param display - HTML element for experiment.
|
|
327
|
+
* @param id - ID string of Image element
|
|
328
|
+
* @returns Image Element
|
|
329
|
+
*/
|
|
330
|
+
private getImg;
|
|
331
|
+
/**
|
|
332
|
+
* Add record button to HTML.
|
|
333
|
+
*
|
|
334
|
+
* @param display - HTML element for experiment.
|
|
335
|
+
*/
|
|
336
|
+
private recordButton;
|
|
337
|
+
/**
|
|
338
|
+
* Set up play button to playback last recorded video.
|
|
339
|
+
*
|
|
340
|
+
* @param display - HTML element for experiment.
|
|
341
|
+
*/
|
|
342
|
+
private playButton;
|
|
343
|
+
/**
|
|
344
|
+
* Add stop button to HTML.
|
|
345
|
+
*
|
|
346
|
+
* @param display - HTML element for experiment.
|
|
347
|
+
*/
|
|
348
|
+
private stopButton;
|
|
349
|
+
/**
|
|
350
|
+
* Add next button to HTML.
|
|
351
|
+
*
|
|
352
|
+
* @param display - HTML element for experiment.
|
|
353
|
+
*/
|
|
354
|
+
private nextButton;
|
|
355
|
+
/**
|
|
356
|
+
* Mark the response in the lookit-api database as having completed the
|
|
357
|
+
* consent frame, then finish the trial.
|
|
358
|
+
*/
|
|
359
|
+
private endTrial;
|
|
360
|
+
/**
|
|
361
|
+
* Add CHS type to experiment data. This will enable Lookit API to run the
|
|
362
|
+
* "consent" Frame Action Dispatcher method after the experiment has
|
|
363
|
+
* completed.
|
|
364
|
+
*
|
|
365
|
+
* @returns Object containing CHS type.
|
|
366
|
+
*/
|
|
367
|
+
static chsData(): {
|
|
368
|
+
chs_type: string;
|
|
369
|
+
};
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
declare const info$2: {
|
|
373
|
+
readonly name: "start-record-plugin";
|
|
374
|
+
readonly parameters: {};
|
|
375
|
+
};
|
|
376
|
+
type Info$2 = typeof info$2;
|
|
377
|
+
/** Start recording. Used by researchers who want to record across trials. */
|
|
378
|
+
declare class StartRecordPlugin implements JsPsychPlugin<Info$2> {
|
|
379
|
+
private jsPsych;
|
|
380
|
+
static readonly info: {
|
|
381
|
+
readonly name: "start-record-plugin";
|
|
382
|
+
readonly parameters: {};
|
|
383
|
+
};
|
|
384
|
+
private recorder;
|
|
385
|
+
/**
|
|
386
|
+
* Plugin used to start recording.
|
|
387
|
+
*
|
|
388
|
+
* @param jsPsych - Object provided by jsPsych.
|
|
389
|
+
*/
|
|
390
|
+
constructor(jsPsych: JsPsych);
|
|
391
|
+
/** Trial function called by jsPsych. */
|
|
392
|
+
trial(): void;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
declare const info$1: {
|
|
396
|
+
readonly name: "stop-record-plugin";
|
|
397
|
+
readonly parameters: {
|
|
398
|
+
readonly locale: {
|
|
399
|
+
readonly type: ParameterType.STRING;
|
|
400
|
+
readonly default: "en-us";
|
|
401
|
+
};
|
|
402
|
+
};
|
|
403
|
+
};
|
|
404
|
+
type Info$1 = typeof info$1;
|
|
405
|
+
/** Stop recording. Used by researchers who want to record across trials. */
|
|
406
|
+
declare class StopRecordPlugin implements JsPsychPlugin<Info$1> {
|
|
407
|
+
private jsPsych;
|
|
408
|
+
static readonly info: {
|
|
409
|
+
readonly name: "stop-record-plugin";
|
|
410
|
+
readonly parameters: {
|
|
411
|
+
readonly locale: {
|
|
412
|
+
readonly type: ParameterType.STRING;
|
|
413
|
+
readonly default: "en-us";
|
|
414
|
+
};
|
|
415
|
+
};
|
|
416
|
+
};
|
|
417
|
+
private recorder;
|
|
418
|
+
/**
|
|
419
|
+
* Plugin used to stop recording.
|
|
420
|
+
*
|
|
421
|
+
* @param jsPsych - Object provided by jsPsych.
|
|
422
|
+
*/
|
|
423
|
+
constructor(jsPsych: JsPsych);
|
|
424
|
+
/**
|
|
425
|
+
* Trial function called by jsPsych.
|
|
426
|
+
*
|
|
427
|
+
* @param display_element - DOM element where jsPsych content is being
|
|
428
|
+
* rendered (set in initJsPsych and automatically made available to a
|
|
429
|
+
* plugin's trial method via jsPsych core).
|
|
430
|
+
* @param trial - Trial object with parameters/values.
|
|
431
|
+
*/
|
|
432
|
+
trial(display_element: HTMLElement, trial: TrialType<Info$1>): void;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/** This extension will allow reasearchers to record trials. */
|
|
436
|
+
declare class TrialRecordExtension implements JsPsychExtension {
|
|
437
|
+
private jsPsych;
|
|
438
|
+
static readonly info: JsPsychExtensionInfo;
|
|
439
|
+
private recorder?;
|
|
440
|
+
private pluginName;
|
|
441
|
+
/**
|
|
442
|
+
* Video recording extension.
|
|
443
|
+
*
|
|
444
|
+
* @param jsPsych - JsPsych object passed into extensions.
|
|
445
|
+
*/
|
|
446
|
+
constructor(jsPsych: JsPsych);
|
|
447
|
+
/**
|
|
448
|
+
* Ran on the initialize step for extensions, called when an instance of
|
|
449
|
+
* jsPsych is first initialized through initJsPsych().
|
|
450
|
+
*/
|
|
451
|
+
initialize(): Promise<void>;
|
|
452
|
+
/** Ran at the start of a trial. */
|
|
453
|
+
on_start(): void;
|
|
454
|
+
/** Ran when the trial has loaded. */
|
|
455
|
+
on_load(): void;
|
|
456
|
+
/**
|
|
457
|
+
* Ran when trial has finished.
|
|
458
|
+
*
|
|
459
|
+
* @returns Trial data.
|
|
460
|
+
*/
|
|
461
|
+
on_finish(): {};
|
|
462
|
+
/**
|
|
463
|
+
* Gets the plugin name for the trial that is being extended. This is same as
|
|
464
|
+
* the "trial_type" value that is stored in the data for this trial.
|
|
465
|
+
*
|
|
466
|
+
* @returns Plugin name string from the plugin class's info.
|
|
467
|
+
*/
|
|
468
|
+
private getCurrentPluginName;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
declare const info: {
|
|
472
|
+
readonly name: "video-config-plugin";
|
|
473
|
+
readonly version: string;
|
|
474
|
+
readonly parameters: {
|
|
475
|
+
readonly locale: {
|
|
476
|
+
readonly type: ParameterType.STRING;
|
|
477
|
+
readonly default: "en-us";
|
|
478
|
+
};
|
|
479
|
+
readonly troubleshooting_intro: {
|
|
480
|
+
/**
|
|
481
|
+
* Optional string to appear at the start of the "Setup tips and
|
|
482
|
+
* troubleshooting" section.
|
|
483
|
+
*/
|
|
484
|
+
readonly type: ParameterType.HTML_STRING;
|
|
485
|
+
readonly default: "";
|
|
486
|
+
readonly pretty_name: "Troubleshooting Intro";
|
|
487
|
+
};
|
|
488
|
+
};
|
|
489
|
+
readonly data: {
|
|
490
|
+
readonly rt: {
|
|
491
|
+
readonly type: ParameterType.INT;
|
|
492
|
+
};
|
|
493
|
+
readonly camId: {
|
|
494
|
+
readonly type: ParameterType.STRING;
|
|
495
|
+
};
|
|
496
|
+
readonly micId: {
|
|
497
|
+
readonly type: ParameterType.STRING;
|
|
498
|
+
};
|
|
499
|
+
};
|
|
500
|
+
};
|
|
501
|
+
type Info = typeof info;
|
|
502
|
+
type VideoConsentTrialType = TrialType<Info>;
|
|
503
|
+
/**
|
|
504
|
+
* **Video Config**.
|
|
505
|
+
*
|
|
506
|
+
* CHS jsPsych plugin for presenting a video recording configuration plugin, to
|
|
507
|
+
* help participants set up their webcam and microphone before beginning a study
|
|
508
|
+
* that includes video/audio recording. This plugin must be used before any
|
|
509
|
+
* other trials in the experiment can access the camera/mic.
|
|
510
|
+
*
|
|
511
|
+
* @author Becky Gilbert
|
|
512
|
+
* @see {@link https://github.com/lookit/lookit-jspsych/blob/main/packages/video-config/README.md video-config plugin documentation on Github}
|
|
513
|
+
*/
|
|
514
|
+
declare class VideoConfigPlugin implements JsPsychPlugin<Info> {
|
|
515
|
+
private jsPsych;
|
|
516
|
+
static info: {
|
|
517
|
+
readonly name: "video-config-plugin";
|
|
518
|
+
readonly version: string;
|
|
519
|
+
readonly parameters: {
|
|
520
|
+
readonly locale: {
|
|
521
|
+
readonly type: ParameterType.STRING;
|
|
522
|
+
readonly default: "en-us";
|
|
523
|
+
};
|
|
524
|
+
readonly troubleshooting_intro: {
|
|
525
|
+
/**
|
|
526
|
+
* Optional string to appear at the start of the "Setup tips and
|
|
527
|
+
* troubleshooting" section.
|
|
528
|
+
*/
|
|
529
|
+
readonly type: ParameterType.HTML_STRING;
|
|
530
|
+
readonly default: "";
|
|
531
|
+
readonly pretty_name: "Troubleshooting Intro";
|
|
532
|
+
};
|
|
533
|
+
};
|
|
534
|
+
readonly data: {
|
|
535
|
+
readonly rt: {
|
|
536
|
+
readonly type: ParameterType.INT;
|
|
537
|
+
};
|
|
538
|
+
readonly camId: {
|
|
539
|
+
readonly type: ParameterType.STRING;
|
|
540
|
+
};
|
|
541
|
+
readonly micId: {
|
|
542
|
+
readonly type: ParameterType.STRING;
|
|
543
|
+
};
|
|
544
|
+
};
|
|
545
|
+
};
|
|
546
|
+
private display_el;
|
|
547
|
+
private start_time;
|
|
548
|
+
private recorder;
|
|
549
|
+
private hasReloaded;
|
|
550
|
+
private response;
|
|
551
|
+
private camId;
|
|
552
|
+
private micId;
|
|
553
|
+
private minVolume;
|
|
554
|
+
private micChecked;
|
|
555
|
+
private processorNode;
|
|
556
|
+
/**
|
|
557
|
+
* Constructor for video config plugin.
|
|
558
|
+
*
|
|
559
|
+
* @param jsPsych - JsPsych object automatically passed into the constructor.
|
|
560
|
+
*/
|
|
561
|
+
constructor(jsPsych: JsPsych);
|
|
562
|
+
/**
|
|
563
|
+
* Trial method called by jsPsych.
|
|
564
|
+
*
|
|
565
|
+
* @param display_element - Element where the jsPsych trial will be displayed.
|
|
566
|
+
* @param trial - Trial object with parameters/values.
|
|
567
|
+
*/
|
|
568
|
+
trial(display_element: HTMLElement, trial: VideoConsentTrialType): void;
|
|
569
|
+
/**
|
|
570
|
+
* Add HTML content to the page.
|
|
571
|
+
*
|
|
572
|
+
* @param trial - Trial object.
|
|
573
|
+
*/
|
|
574
|
+
private addHtmlContent;
|
|
575
|
+
/** Add event listeners to elements after they've been added to the page. */
|
|
576
|
+
private addEventListeners;
|
|
577
|
+
/**
|
|
578
|
+
* Access media devices, populate device lists, setup the jsPsych
|
|
579
|
+
* camera/stream and Recorder instance, and run the permissions/mic checks.
|
|
580
|
+
* This is run when the trial first loads and anytime the user clicks the
|
|
581
|
+
* reload recorder button.
|
|
582
|
+
*
|
|
583
|
+
* 1. Request permissions.
|
|
584
|
+
* 2. Enumerate devices and populate the device selection elements with options.
|
|
585
|
+
* 3. Initialize the jsPsych recorder with the current/selected devices, and
|
|
586
|
+
* create a new Recorder.
|
|
587
|
+
* 4. Run the stream checks. (If completed successfully, this will clear any
|
|
588
|
+
* error messages and enable the next button).
|
|
589
|
+
*/
|
|
590
|
+
private setupRecorder;
|
|
591
|
+
/**
|
|
592
|
+
* Request permission to use the webcam and/or microphone. This can be used
|
|
593
|
+
* with and without specific device selection (and other constraints).
|
|
594
|
+
*
|
|
595
|
+
* @param constraints - Media stream constraints object with 'video' and
|
|
596
|
+
* 'audio' properties, whose values can be boolean or a
|
|
597
|
+
* MediaTrackConstraints object or undefined.
|
|
598
|
+
* @param constraints.video - If false, do not include video. If true, use the
|
|
599
|
+
* default webcam device. If a media track constraints object is passed,
|
|
600
|
+
* then it can contain the properties of all media tracks and video tracks:
|
|
601
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints.
|
|
602
|
+
* @param constraints.audio - If false, do not include audio. If true, use the
|
|
603
|
+
* default mic device. If a media track constraints object is passed, then
|
|
604
|
+
* it can contain the properties of all media tracks and audio tracks:
|
|
605
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints.
|
|
606
|
+
* @returns Camera/microphone stream.
|
|
607
|
+
*/
|
|
608
|
+
private requestPermission;
|
|
609
|
+
/**
|
|
610
|
+
* Receives device lists and populates the device selection HTML elements.
|
|
611
|
+
* This is run when the trial loads, and in response to changes to the
|
|
612
|
+
* available devices.
|
|
613
|
+
*
|
|
614
|
+
* @param devices - Object with properties 'cameras' and 'mics', which are
|
|
615
|
+
* arrays containing lists of available devices.
|
|
616
|
+
* @param devices.cameras - Array of MediaDeviceInfo objects for webcam/video
|
|
617
|
+
* input devices.
|
|
618
|
+
* @param devices.mics - Array of MediaDeviceInfo objects for mic/audio input
|
|
619
|
+
* devices.
|
|
620
|
+
*/
|
|
621
|
+
private updateDeviceSelection;
|
|
622
|
+
/**
|
|
623
|
+
* Takes the selected device IDs from the camera/mic selection elements, gets
|
|
624
|
+
* the streams for these devices, sets these as the input devices via
|
|
625
|
+
* jsPsych.pluginAPI.initializeCameraRecorder, and creates a new Recorder.
|
|
626
|
+
*/
|
|
627
|
+
private setDevices;
|
|
628
|
+
/**
|
|
629
|
+
* Run the stream checks after permissions have been granted and devices have
|
|
630
|
+
* been selected. This is run when the trial first loads, after permissions
|
|
631
|
+
* are granted, and in response to changes to the device selection. It checks
|
|
632
|
+
* for (1) the existence of the required streams, (2) minimum microphone input
|
|
633
|
+
* level (when audio is included), and (3) media permissions (via recorder
|
|
634
|
+
* destroy/reload). This runs the stream checks, updates the info/error
|
|
635
|
+
* messages, enables the next button, and handles errors. This is factored out
|
|
636
|
+
* of the set up process (setupRecorder) because it is also triggered by a
|
|
637
|
+
* change in the cam/mic device selection.
|
|
638
|
+
*/
|
|
639
|
+
private runStreamChecks;
|
|
640
|
+
/**
|
|
641
|
+
* If there is a change to the available devices, then we need to: (1) get the
|
|
642
|
+
* updated device lists, and (2) update the select elements with these list
|
|
643
|
+
* elements.
|
|
644
|
+
*/
|
|
645
|
+
private onDeviceChange;
|
|
646
|
+
/**
|
|
647
|
+
* Gets the lists of available cameras and mics (via Media Devices
|
|
648
|
+
* 'enumerateDevices'). These lists can be used to populate camera/mic
|
|
649
|
+
* selection elements.
|
|
650
|
+
*
|
|
651
|
+
* @param include_audio - Whether or not to include audio capture (mic)
|
|
652
|
+
* devices. Optional, default is true.
|
|
653
|
+
* @param include_camera - Whether or not to include the webcam (video)
|
|
654
|
+
* devices. Optional, default is true.
|
|
655
|
+
* @returns Object with properties 'cameras' and 'mics', containing lists of
|
|
656
|
+
* available devices.
|
|
657
|
+
*/
|
|
658
|
+
private getDeviceLists;
|
|
659
|
+
/**
|
|
660
|
+
* Initialize recorder using the jsPsych plugin API. This must be called
|
|
661
|
+
* before running the stream checks.
|
|
662
|
+
*
|
|
663
|
+
* @param stream - Media stream returned from getUserMedia that should be used
|
|
664
|
+
* to set up the jsPsych recorder.
|
|
665
|
+
* @param opts - Media recorder options to use when setting up the recorder.
|
|
666
|
+
*/
|
|
667
|
+
initializeAndCreateRecorder: (stream: MediaStream, opts?: MediaRecorderOptions) => void;
|
|
668
|
+
/**
|
|
669
|
+
* Perform a sound check on the audio input (microphone).
|
|
670
|
+
*
|
|
671
|
+
* @param minVol - Minimum mic activity needed to reach the mic check
|
|
672
|
+
* threshold (optional). Default is `this.minVolume`
|
|
673
|
+
* @returns Promise that resolves when the mic check is complete because the
|
|
674
|
+
* audio stream has reached the required minimum level.
|
|
675
|
+
*/
|
|
676
|
+
private checkMic;
|
|
677
|
+
/**
|
|
678
|
+
* Handle the mic level messages that are sent via an AudioWorkletProcessor.
|
|
679
|
+
* This checks the current level against the minimum threshold, and if the
|
|
680
|
+
* threshold is met, sets the micChecked property to true and resolves the
|
|
681
|
+
* checkMic promise.
|
|
682
|
+
*
|
|
683
|
+
* @param currentActivityLevel - Microphone activity level calculated by the
|
|
684
|
+
* processor node.
|
|
685
|
+
* @param minVolume - Minimum microphone activity level needed to pass the
|
|
686
|
+
* microphone check.
|
|
687
|
+
* @param resolve - Resolve callback function for Promise returned by the
|
|
688
|
+
* checkMic method.
|
|
689
|
+
*/
|
|
690
|
+
private onMicActivityLevel;
|
|
691
|
+
/**
|
|
692
|
+
* Creates the processor node for the mic check input level processing, and
|
|
693
|
+
* connects the microphone to the processor node.
|
|
694
|
+
*
|
|
695
|
+
* @param audioContext - Audio context that was created in checkMic. This is
|
|
696
|
+
* used to create the processor node.
|
|
697
|
+
* @param microphone - Microphone audio stream source, created in checkMic.
|
|
698
|
+
* The processor node will be connected to this source.
|
|
699
|
+
* @returns Promise that resolves after the processor node has been created,
|
|
700
|
+
* and the microphone audio stream source is connected to the processor node
|
|
701
|
+
* and audio context destination.
|
|
702
|
+
*/
|
|
703
|
+
private createConnectProcessor;
|
|
704
|
+
/**
|
|
705
|
+
* Set up the port's on message event handler for the mic check processor
|
|
706
|
+
* node. This adds the event related callback, which calls onMicActivityLevel
|
|
707
|
+
* with the event data.
|
|
708
|
+
*
|
|
709
|
+
* @param minVol - Minimum volume level (RMS amplitude) passed from checkMic.
|
|
710
|
+
* @returns Promise that resolves from inside the onMicActivityLevel callback,
|
|
711
|
+
* when the mic stream input level has reached the threshold.
|
|
712
|
+
*/
|
|
713
|
+
private setupPortOnMessage;
|
|
714
|
+
/**
|
|
715
|
+
* Update the instructions for a given step, based on whether or not the check
|
|
716
|
+
* has passed for that step.
|
|
717
|
+
*
|
|
718
|
+
* @param step - Which instructions step to update. 1 = stream access, 2 =
|
|
719
|
+
* reload complete, 3 = mic level check.
|
|
720
|
+
* @param checkPassed - Whether or not the mic check has passed.
|
|
721
|
+
*/
|
|
722
|
+
private updateInstructions;
|
|
723
|
+
/**
|
|
724
|
+
* Update the errors/messages div with information for the user about the
|
|
725
|
+
* camera/mic checks.
|
|
726
|
+
*
|
|
727
|
+
* @param errorMsgId - Span element ID containing the message to display in
|
|
728
|
+
* the error message div. Call the function without an errorMsgId to clear
|
|
729
|
+
* the errors.
|
|
730
|
+
*/
|
|
731
|
+
private updateErrors;
|
|
732
|
+
/**
|
|
733
|
+
* Collect trial data and end the trial. JsPsych.finishTrial takes the
|
|
734
|
+
* plugin's trial data as an argument, ends the trial, and moves on to the
|
|
735
|
+
* next trial in the experiment timeline.
|
|
736
|
+
*/
|
|
737
|
+
private endTrial;
|
|
738
|
+
/**
|
|
739
|
+
* Destroy the recorder. This is used to stop the streams at the end of the
|
|
740
|
+
* trial, and as part of the reload check to test the user's browser
|
|
741
|
+
* permissions by mimicking the start of a new trial (i.e. stop streams and
|
|
742
|
+
* then create a new Recorder instance).
|
|
743
|
+
*/
|
|
744
|
+
private destroyRecorder;
|
|
745
|
+
/** Handle the next button click event. */
|
|
746
|
+
private nextButtonClick;
|
|
747
|
+
/** Handle the reload recorder button click event. */
|
|
748
|
+
private reloadButtonClick;
|
|
749
|
+
/**
|
|
750
|
+
* Toggle the next button disable property.
|
|
751
|
+
*
|
|
752
|
+
* @param enable - Whether to enable (true) or disable (false) the next
|
|
753
|
+
* button.
|
|
754
|
+
*/
|
|
755
|
+
private enableNext;
|
|
756
|
+
}
|
|
757
|
+
|
|
6
758
|
declare const _default: {
|
|
7
759
|
TrialRecordExtension: typeof TrialRecordExtension;
|
|
8
760
|
StartRecordPlugin: typeof StartRecordPlugin;
|
|
@@ -10,4 +762,6 @@ declare const _default: {
|
|
|
10
762
|
VideoConfigPlugin: typeof VideoConfigPlugin;
|
|
11
763
|
VideoConsentPlugin: typeof VideoConsentPlugin;
|
|
12
764
|
};
|
|
13
|
-
|
|
765
|
+
|
|
766
|
+
export { _default as default };
|
|
767
|
+
//# sourceMappingURL=index.d.ts.map
|