@lookit/record 2.0.0 → 3.0.1

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/dist/index.d.ts CHANGED
@@ -1,8 +1,777 @@
1
- import { VideoConsentPlugin } from "./consentVideo";
2
- import StartRecordPlugin from "./start";
3
- import StopRecordPlugin from "./stop";
4
- import TrialRecordExtension from "./trial";
5
- import VideoConfigPlugin from "./videoConfig";
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
+ private mimeType;
557
+ /**
558
+ * Constructor for video config plugin.
559
+ *
560
+ * @param jsPsych - JsPsych object automatically passed into the constructor.
561
+ */
562
+ constructor(jsPsych: JsPsych);
563
+ /**
564
+ * Trial method called by jsPsych.
565
+ *
566
+ * @param display_element - Element where the jsPsych trial will be displayed.
567
+ * @param trial - Trial object with parameters/values.
568
+ */
569
+ trial(display_element: HTMLElement, trial: VideoConsentTrialType): void;
570
+ /**
571
+ * Add HTML content to the page.
572
+ *
573
+ * @param trial - Trial object.
574
+ */
575
+ private addHtmlContent;
576
+ /** Add event listeners to elements after they've been added to the page. */
577
+ private addEventListeners;
578
+ /**
579
+ * Access media devices, populate device lists, setup the jsPsych
580
+ * camera/stream and Recorder instance, and run the permissions/mic checks.
581
+ * This is run when the trial first loads and anytime the user clicks the
582
+ * reload recorder button.
583
+ *
584
+ * 1. Request permissions.
585
+ * 2. Enumerate devices and populate the device selection elements with options.
586
+ * 3. Initialize the jsPsych recorder with the current/selected devices, and
587
+ * create a new Recorder.
588
+ * 4. Run the stream checks. (If completed successfully, this will clear any
589
+ * error messages and enable the next button).
590
+ */
591
+ private setupRecorder;
592
+ /**
593
+ * Request permission to use the webcam and/or microphone. This can be used
594
+ * with and without specific device selection (and other constraints).
595
+ *
596
+ * @param constraints - Media stream constraints object with 'video' and
597
+ * 'audio' properties, whose values can be boolean or a
598
+ * MediaTrackConstraints object or undefined.
599
+ * @param constraints.video - If false, do not include video. If true, use the
600
+ * default webcam device. If a media track constraints object is passed,
601
+ * then it can contain the properties of all media tracks and video tracks:
602
+ * https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints.
603
+ * @param constraints.audio - If false, do not include audio. If true, use the
604
+ * default mic device. If a media track constraints object is passed, then
605
+ * it can contain the properties of all media tracks and audio tracks:
606
+ * https://developer.mozilla.org/en-US/docs/Web/API/MediaTrackConstraints.
607
+ * @returns Camera/microphone stream.
608
+ */
609
+ private requestPermission;
610
+ /**
611
+ * Receives device lists and populates the device selection HTML elements.
612
+ * This is run when the trial loads, and in response to changes to the
613
+ * available devices.
614
+ *
615
+ * @param devices - Object with properties 'cameras' and 'mics', which are
616
+ * arrays containing lists of available devices.
617
+ * @param devices.cameras - Array of MediaDeviceInfo objects for webcam/video
618
+ * input devices.
619
+ * @param devices.mics - Array of MediaDeviceInfo objects for mic/audio input
620
+ * devices.
621
+ */
622
+ private updateDeviceSelection;
623
+ /**
624
+ * Takes the selected device IDs from the camera/mic selection elements, gets
625
+ * the streams for these devices, sets these as the input devices via
626
+ * jsPsych.pluginAPI.initializeCameraRecorder, and creates a new Recorder.
627
+ */
628
+ private setDevices;
629
+ /**
630
+ * Run the stream checks after permissions have been granted and devices have
631
+ * been selected. This is run when the trial first loads, after permissions
632
+ * are granted, and in response to changes to the device selection. It checks
633
+ * for (1) the existence of the required streams, (2) minimum microphone input
634
+ * level (when audio is included), and (3) media permissions (via recorder
635
+ * destroy/reload). This runs the stream checks, updates the info/error
636
+ * messages, enables the next button, and handles errors. This is factored out
637
+ * of the set up process (setupRecorder) because it is also triggered by a
638
+ * change in the cam/mic device selection.
639
+ */
640
+ private runStreamChecks;
641
+ /**
642
+ * If there is a change to the available devices, then we need to: (1) get the
643
+ * updated device lists, and (2) update the select elements with these list
644
+ * elements.
645
+ */
646
+ private onDeviceChange;
647
+ /**
648
+ * Gets the lists of available cameras and mics (via Media Devices
649
+ * 'enumerateDevices'). These lists can be used to populate camera/mic
650
+ * selection elements.
651
+ *
652
+ * @param include_audio - Whether or not to include audio capture (mic)
653
+ * devices. Optional, default is true.
654
+ * @param include_camera - Whether or not to include the webcam (video)
655
+ * devices. Optional, default is true.
656
+ * @returns Object with properties 'cameras' and 'mics', containing lists of
657
+ * available devices.
658
+ */
659
+ private getDeviceLists;
660
+ /**
661
+ * Initialize recorder using the jsPsych plugin API. This must be called
662
+ * before running the stream checks.
663
+ *
664
+ * @param stream - Media stream returned from getUserMedia that should be used
665
+ * to set up the jsPsych recorder.
666
+ * @param opts - Media recorder options to use when setting up the recorder.
667
+ * This will include the mimeType property that is set via getMimeTypeCodec,
668
+ * as well as any other options that can passed via the calling context.
669
+ */
670
+ initializeAndCreateRecorder: (stream: MediaStream, opts?: MediaRecorderOptions) => void;
671
+ /**
672
+ * Perform a sound check on the audio input (microphone).
673
+ *
674
+ * @param minVol - Minimum mic activity needed to reach the mic check
675
+ * threshold (optional). Default is `this.minVolume`
676
+ * @returns Promise that resolves when the mic check is complete because the
677
+ * audio stream has reached the required minimum level.
678
+ */
679
+ private checkMic;
680
+ /**
681
+ * Handle the mic level messages that are sent via an AudioWorkletProcessor.
682
+ * This checks the current level against the minimum threshold, and if the
683
+ * threshold is met, sets the micChecked property to true and resolves the
684
+ * checkMic promise.
685
+ *
686
+ * @param currentActivityLevel - Microphone activity level calculated by the
687
+ * processor node.
688
+ * @param minVolume - Minimum microphone activity level needed to pass the
689
+ * microphone check.
690
+ * @param resolve - Resolve callback function for Promise returned by the
691
+ * checkMic method.
692
+ */
693
+ private onMicActivityLevel;
694
+ /**
695
+ * Creates the processor node for the mic check input level processing, and
696
+ * connects the microphone to the processor node.
697
+ *
698
+ * @param audioContext - Audio context that was created in checkMic. This is
699
+ * used to create the processor node.
700
+ * @param microphone - Microphone audio stream source, created in checkMic.
701
+ * The processor node will be connected to this source.
702
+ * @returns Promise that resolves after the processor node has been created,
703
+ * and the microphone audio stream source is connected to the processor node
704
+ * and audio context destination.
705
+ */
706
+ private createConnectProcessor;
707
+ /**
708
+ * Set up the port's on message event handler for the mic check processor
709
+ * node. This adds the event related callback, which calls onMicActivityLevel
710
+ * with the event data.
711
+ *
712
+ * @param minVol - Minimum volume level (RMS amplitude) passed from checkMic.
713
+ * @returns Promise that resolves from inside the onMicActivityLevel callback,
714
+ * when the mic stream input level has reached the threshold.
715
+ */
716
+ private setupPortOnMessage;
717
+ /**
718
+ * Update the instructions for a given step, based on whether or not the check
719
+ * has passed for that step.
720
+ *
721
+ * @param step - Which instructions step to update. 1 = stream access, 2 =
722
+ * reload complete, 3 = mic level check.
723
+ * @param checkPassed - Whether or not the mic check has passed.
724
+ */
725
+ private updateInstructions;
726
+ /**
727
+ * Update the errors/messages div with information for the user about the
728
+ * camera/mic checks.
729
+ *
730
+ * @param errorMsgId - Span element ID containing the message to display in
731
+ * the error message div. Call the function without an errorMsgId to clear
732
+ * the errors.
733
+ */
734
+ private updateErrors;
735
+ /**
736
+ * Collect trial data and end the trial. JsPsych.finishTrial takes the
737
+ * plugin's trial data as an argument, ends the trial, and moves on to the
738
+ * next trial in the experiment timeline.
739
+ */
740
+ private endTrial;
741
+ /**
742
+ * Destroy the recorder. This is used to stop the streams at the end of the
743
+ * trial, and as part of the reload check to test the user's browser
744
+ * permissions by mimicking the start of a new trial (i.e. stop streams and
745
+ * then create a new Recorder instance).
746
+ */
747
+ private destroyRecorder;
748
+ /** Handle the next button click event. */
749
+ private nextButtonClick;
750
+ /** Handle the reload recorder button click event. */
751
+ private reloadButtonClick;
752
+ /**
753
+ * Toggle the next button disable property.
754
+ *
755
+ * @param enable - Whether to enable (true) or disable (false) the next
756
+ * button.
757
+ */
758
+ private enableNext;
759
+ /**
760
+ * Check support for recording containers/codecs, in order of preference, and
761
+ * get the first supported type. The first supported type found in the
762
+ * mime_types array is returned and will be passed to the "mimeType" property
763
+ * in the recorder options object that is passed to the recorder
764
+ * initialization function (jsPsych.pluginAPI.initializeCameraRecorder). If
765
+ * none of these types is supported, the function returns null.
766
+ *
767
+ * Note: we will likely need to continuously update the mime_types list as new
768
+ * formats become supported, we support other browsers/versions, etc.
769
+ *
770
+ * @returns Mime type string, or null (if none from the array are supported).
771
+ */
772
+ private getCompatibleMimeType;
773
+ }
774
+
6
775
  declare const _default: {
7
776
  TrialRecordExtension: typeof TrialRecordExtension;
8
777
  StartRecordPlugin: typeof StartRecordPlugin;
@@ -10,4 +779,6 @@ declare const _default: {
10
779
  VideoConfigPlugin: typeof VideoConfigPlugin;
11
780
  VideoConsentPlugin: typeof VideoConsentPlugin;
12
781
  };
13
- export default _default;
782
+
783
+ export { _default as default };
784
+ //# sourceMappingURL=index.d.ts.map