@lookit/record 3.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/README.md +125 -39
- package/dist/index.browser.js +30 -4
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.min.js +13 -13
- package/dist/index.browser.min.js.map +1 -1
- package/dist/index.cjs +29 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +17 -0
- package/dist/index.js +29 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/recorder.spec.ts +88 -1
- package/src/recorder.ts +8 -1
- package/src/videoConfig.spec.ts +115 -0
- package/src/videoConfig.ts +38 -1
package/README.md
CHANGED
|
@@ -25,7 +25,7 @@ following language codes:
|
|
|
25
25
|
| Portuguese | Brazil | pt-BR |
|
|
26
26
|
| Portuguese | | pt |
|
|
27
27
|
|
|
28
|
-
## Video Configuration
|
|
28
|
+
## Video Configuration Plugin
|
|
29
29
|
|
|
30
30
|
To record _any_ video during an experiment, including a consent video, you must
|
|
31
31
|
add a video configuration trial. This trial allows the user to give permissions
|
|
@@ -61,51 +61,20 @@ const videoConfig = {
|
|
|
61
61
|
};
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
-
## Video Consent
|
|
64
|
+
## Video Consent Plugin
|
|
65
65
|
|
|
66
66
|
Users will need to record themselves accepting the consent document for your
|
|
67
67
|
study. This trial will allow the user to read the consent document and record a
|
|
68
68
|
video accepting it.
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
!!! caution "Don't forget a video config trial!"
|
|
71
71
|
|
|
72
|
-
|
|
73
|
-
const videoConsent = { type: chsRecord.VideoConsentPlugin, ...parameters };
|
|
74
|
-
```
|
|
72
|
+
You MUST have a video config trial in your experiment timeline before the video consent trial.
|
|
75
73
|
|
|
76
|
-
|
|
74
|
+
To create the video consent trial:
|
|
77
75
|
|
|
78
76
|
```javascript
|
|
79
|
-
const videoConsent = {
|
|
80
|
-
type: chsRecord.VideoConsentPlugin,
|
|
81
|
-
PIName: "Jane Smith",
|
|
82
|
-
institution: "Science University",
|
|
83
|
-
PIContact: "Jane Smith at 123 456 7890",
|
|
84
|
-
purpose:
|
|
85
|
-
"Why do babies love cats? This study will help us find out whether babies love cats because of their soft fur or their twitchy tails.",
|
|
86
|
-
procedures:
|
|
87
|
-
"Your child will be shown pictures of lots of different cats, along with noises that cats make like meowing and purring. We are interested in which pictures and sounds make your child smile. We will ask you (the parent) to turn around to avoid influencing your child's responses.",
|
|
88
|
-
risk_statement:
|
|
89
|
-
"There are no expected risks if you participate in the study. (This is optional, but should typically be included. If you leave it out there's no 'risks' section and you should include risk information elsewhere.)",
|
|
90
|
-
voluntary_participation:
|
|
91
|
-
"There are two sessions in this study; you will be invited to complete another session next month. It is okay not to do both sessions! (This is optional; leave it out if you don't need to say anything besides participation in this session being voluntary.)",
|
|
92
|
-
payment:
|
|
93
|
-
"After you finish the study, we will email you a $5 BabyStore gift card within approximately three days. To be eligible for the gift card your child must be in the age range for this study, you need to submit a valid consent statement, and we need to see that there is a child with you. But we will send a gift card even if you do not finish the whole study or we are not able to use your child's data! There are no other direct benefits to you or your child from participating, but we hope you will enjoy the experience.",
|
|
94
|
-
datause:
|
|
95
|
-
"We are primarily interested in your child's emotional reactions to the images and sounds. A research assistant will watch your video to measure the precise amount of delight in your child's face as he or she sees each cat picture.",
|
|
96
|
-
include_databrary: true,
|
|
97
|
-
additional_video_privacy_statement:
|
|
98
|
-
"We will also ask your permission to use your videos as stimuli for other parents. (This is optional; leave it out if there aren't additional ways you'll share video beyond as described in the participant's video privacy level and Databrary selections.)",
|
|
99
|
-
gdpr: false,
|
|
100
|
-
research_rights_statement:
|
|
101
|
-
"You are not waiving any legal claims, rights or remedies because of your participation in this research study. If you feel you have been treated unfairly, or you have questions regarding your rights as a research subject, you may contact the [IRB NAME], [INSTITUTION], [ADDRESS/CONTACT]",
|
|
102
|
-
additional_segments: [
|
|
103
|
-
{
|
|
104
|
-
title: "US Patriot Act Disclosure",
|
|
105
|
-
text: "[EXAMPLE ONLY, PLEASE REMOVE ADDITIONAL_SEGMENTS UNLESS YOU NEED THEM.] Lookit is a U.S. organization and all information gathered from the website is stored on servers based in the U.S. Therefore, your video recordings are subject to U.S. laws, such as the US Patriot Act. This act allows authorities access to the records of internet service providers. If you choose to participate in this study, you understand that your video recording will be stored and accessed in the USA. The security and privacy policy for Lookit can be found at the following link: <a href='https://lookit.mit.edu/privacy/' target='_blank' rel='noopener'>https://lookit.mit.edu/privacy/</a>.",
|
|
106
|
-
},
|
|
107
|
-
],
|
|
108
|
-
};
|
|
77
|
+
const videoConsent = { type: chsRecord.VideoConsentPlugin, ...parameters };
|
|
109
78
|
```
|
|
110
79
|
|
|
111
80
|
### Parameters
|
|
@@ -328,7 +297,68 @@ Replace the default spoken consent statement with your custom text.
|
|
|
328
297
|
Whether to omit the phrase “or in the very unlikely event of a research-related
|
|
329
298
|
injury” from the contact section. (This was required by the Northwestern IRB.)
|
|
330
299
|
|
|
331
|
-
|
|
300
|
+
### Example
|
|
301
|
+
|
|
302
|
+
```javascript
|
|
303
|
+
const videoConsent = {
|
|
304
|
+
type: chsRecord.VideoConsentPlugin,
|
|
305
|
+
PIName: "Jane Smith",
|
|
306
|
+
institution: "Science University",
|
|
307
|
+
PIContact: "Jane Smith at 123 456 7890",
|
|
308
|
+
purpose:
|
|
309
|
+
"Why do babies love cats? This study will help us find out whether babies love cats because of their soft fur or their twitchy tails.",
|
|
310
|
+
procedures:
|
|
311
|
+
"Your child will be shown pictures of lots of different cats, along with noises that cats make like meowing and purring. We are interested in which pictures and sounds make your child smile. We will ask you (the parent) to turn around to avoid influencing your child's responses.",
|
|
312
|
+
risk_statement:
|
|
313
|
+
"There are no expected risks if you participate in the study. (This is optional, but should typically be included. If you leave it out there's no 'risks' section and you should include risk information elsewhere.)",
|
|
314
|
+
voluntary_participation:
|
|
315
|
+
"There are two sessions in this study; you will be invited to complete another session next month. It is okay not to do both sessions! (This is optional; leave it out if you don't need to say anything besides participation in this session being voluntary.)",
|
|
316
|
+
payment:
|
|
317
|
+
"After you finish the study, we will email you a $5 BabyStore gift card within approximately three days. To be eligible for the gift card your child must be in the age range for this study, you need to submit a valid consent statement, and we need to see that there is a child with you. But we will send a gift card even if you do not finish the whole study or we are not able to use your child's data! There are no other direct benefits to you or your child from participating, but we hope you will enjoy the experience.",
|
|
318
|
+
datause:
|
|
319
|
+
"We are primarily interested in your child's emotional reactions to the images and sounds. A research assistant will watch your video to measure the precise amount of delight in your child's face as he or she sees each cat picture.",
|
|
320
|
+
include_databrary: true,
|
|
321
|
+
additional_video_privacy_statement:
|
|
322
|
+
"We will also ask your permission to use your videos as stimuli for other parents. (This is optional; leave it out if there aren't additional ways you'll share video beyond as described in the participant's video privacy level and Databrary selections.)",
|
|
323
|
+
gdpr: false,
|
|
324
|
+
research_rights_statement:
|
|
325
|
+
"You are not waiving any legal claims, rights or remedies because of your participation in this research study. If you feel you have been treated unfairly, or you have questions regarding your rights as a research subject, you may contact the [IRB NAME], [INSTITUTION], [ADDRESS/CONTACT]",
|
|
326
|
+
additional_segments: [
|
|
327
|
+
{
|
|
328
|
+
title: "US Patriot Act Disclosure",
|
|
329
|
+
text: "[EXAMPLE ONLY, PLEASE REMOVE ADDITIONAL_SEGMENTS UNLESS YOU NEED THEM.] Lookit is a U.S. organization and all information gathered from the website is stored on servers based in the U.S. Therefore, your video recordings are subject to U.S. laws, such as the US Patriot Act. This act allows authorities access to the records of internet service providers. If you choose to participate in this study, you understand that your video recording will be stored and accessed in the USA. The security and privacy policy for Lookit can be found at the following link: <a href='https://lookit.mit.edu/privacy/' target='_blank' rel='noopener'>https://lookit.mit.edu/privacy/</a>.",
|
|
330
|
+
},
|
|
331
|
+
],
|
|
332
|
+
};
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
## Trial Recording Extension
|
|
336
|
+
|
|
337
|
+
Trial recording can be added to most jsPsych trials. This is a jsPsych extension
|
|
338
|
+
that allows you to add video recording to the trial. The trial will start once
|
|
339
|
+
the video recording has been set up, and the video recording will finish as soon
|
|
340
|
+
as the trial has ended.
|
|
341
|
+
|
|
342
|
+
!!! important "When to use trial recording"
|
|
343
|
+
|
|
344
|
+
Trial recording should NOT occur simultaneously with session recording, or with any plugins that already use the webcam (e.g. video config, video consent).
|
|
345
|
+
|
|
346
|
+
To use the CHS trial recording extension, you need to:
|
|
347
|
+
|
|
348
|
+
1. Add it to the experiment settings, which is an optional object passed to
|
|
349
|
+
`initjsPsych`.
|
|
350
|
+
2. Add it to the `extensions` parameter for any trial(s) that you want to be
|
|
351
|
+
recorded.
|
|
352
|
+
|
|
353
|
+
!!! caution "Don't forget a video config trial!"
|
|
354
|
+
|
|
355
|
+
You MUST have a video config trial in your experiment timeline before doing any trial recording.
|
|
356
|
+
|
|
357
|
+
### Parameters
|
|
358
|
+
|
|
359
|
+
This extension does not accept any parameters.
|
|
360
|
+
|
|
361
|
+
### Example
|
|
332
362
|
|
|
333
363
|
To record a single trial, you will have to first load the extension in
|
|
334
364
|
`initJsPsych`.
|
|
@@ -362,7 +392,48 @@ You might prefer to record across multiple trials in a study session. This can
|
|
|
362
392
|
be done by using trials created with the start and stop recording plugins. This
|
|
363
393
|
gives a bit of flexibility over which of the study trials are recorded.
|
|
364
394
|
|
|
365
|
-
|
|
395
|
+
!!! important "When to use session recording"
|
|
396
|
+
|
|
397
|
+
Sesssion recording should NOT occur simultaneously with trial recording, or with any plugins that already use the webcam (e.g. video config, video consent).
|
|
398
|
+
|
|
399
|
+
To record a set of trials, add a 'start' trial in your jsPsych experiment
|
|
400
|
+
timeline right before you'd like to start recording, and add a 'stop' trial at
|
|
401
|
+
the point in your timeline when you'd like to stop recording.
|
|
402
|
+
|
|
403
|
+
!!! caution "Don't forget a video config trial!"
|
|
404
|
+
|
|
405
|
+
You MUST have a video config trial in your experiment timeline before doing any session recording.
|
|
406
|
+
|
|
407
|
+
### Start Recording Plugin
|
|
408
|
+
|
|
409
|
+
The plugin to start session recording is called `chsRecord.StartRecordPlugin`.
|
|
410
|
+
|
|
411
|
+
```javascript
|
|
412
|
+
const startRec = { type: chsRecord.StartRecordPlugin };
|
|
413
|
+
```
|
|
414
|
+
|
|
415
|
+
#### Parameters
|
|
416
|
+
|
|
417
|
+
This plugin does not accept any parameters, other those available in all
|
|
418
|
+
plugins.
|
|
419
|
+
|
|
420
|
+
### Stop Recording Plugin
|
|
421
|
+
|
|
422
|
+
The plugin to stop session recording is called `chsRecord.StopRecordPlugin`.
|
|
423
|
+
|
|
424
|
+
```javascript
|
|
425
|
+
const stopRec = { type: chsRecord.StopRecordPlugin };
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
#### Parameters
|
|
429
|
+
|
|
430
|
+
This plugin does not accept any parameters, other those available in all
|
|
431
|
+
plugins.
|
|
432
|
+
|
|
433
|
+
### Example
|
|
434
|
+
|
|
435
|
+
First, make sure that you've added a video config trial to your experiment
|
|
436
|
+
timeline. Then, create your start and stop recording trials:
|
|
366
437
|
|
|
367
438
|
```javascript
|
|
368
439
|
const startRec = { type: chsRecord.StartRecordPlugin };
|
|
@@ -390,3 +461,18 @@ stop or start recording trials within the timeline.
|
|
|
390
461
|
```javascript
|
|
391
462
|
jsPsych.run([videoConfig, startRec, morning, evening, stopRec, night]);
|
|
392
463
|
```
|
|
464
|
+
|
|
465
|
+
You can also create more than one session recording:
|
|
466
|
+
|
|
467
|
+
```javascript
|
|
468
|
+
jsPsych.run([
|
|
469
|
+
videoConfig,
|
|
470
|
+
startRec,
|
|
471
|
+
morning,
|
|
472
|
+
stopRec,
|
|
473
|
+
evening,
|
|
474
|
+
startRec,
|
|
475
|
+
night,
|
|
476
|
+
stopRec,
|
|
477
|
+
]);
|
|
478
|
+
```
|
package/dist/index.browser.js
CHANGED
|
@@ -32,7 +32,7 @@ var chsRecord = (function (Data, chsTemplates, jspsych) {
|
|
|
32
32
|
|
|
33
33
|
var _package = {
|
|
34
34
|
name: "@lookit/record",
|
|
35
|
-
version: "3.0.
|
|
35
|
+
version: "3.0.1",
|
|
36
36
|
description: "Recording extensions and plugins for CHS studies.",
|
|
37
37
|
homepage: "https://github.com/lookit/lookit-jspsych#readme",
|
|
38
38
|
bugs: {
|
|
@@ -8481,6 +8481,7 @@ var chsRecord = (function (Data, chsTemplates, jspsych) {
|
|
|
8481
8481
|
this.jsPsych = jsPsych;
|
|
8482
8482
|
this.streamClone = this.stream.clone();
|
|
8483
8483
|
autoBind(this);
|
|
8484
|
+
this.mimeType = this.recorder?.mimeType || this.mimeType;
|
|
8484
8485
|
}
|
|
8485
8486
|
url;
|
|
8486
8487
|
_s3;
|
|
@@ -8489,6 +8490,7 @@ var chsRecord = (function (Data, chsTemplates, jspsych) {
|
|
|
8489
8490
|
filename;
|
|
8490
8491
|
stopPromise;
|
|
8491
8492
|
webcam_element_id = "lookit-jspsych-webcam";
|
|
8493
|
+
mimeType = "video/webm";
|
|
8492
8494
|
streamClone;
|
|
8493
8495
|
get recorder() {
|
|
8494
8496
|
return this.jsPsych.pluginAPI.getCameraRecorder() || this.jsPsych.pluginAPI.getMicrophoneRecorder();
|
|
@@ -8506,7 +8508,11 @@ var chsRecord = (function (Data, chsTemplates, jspsych) {
|
|
|
8506
8508
|
this._s3 = value;
|
|
8507
8509
|
}
|
|
8508
8510
|
initializeRecorder(stream, opts) {
|
|
8509
|
-
|
|
8511
|
+
const recorder_options = {
|
|
8512
|
+
...opts,
|
|
8513
|
+
mimeType: this.mimeType
|
|
8514
|
+
};
|
|
8515
|
+
this.jsPsych.pluginAPI.initializeCameraRecorder(stream, recorder_options);
|
|
8510
8516
|
}
|
|
8511
8517
|
reset() {
|
|
8512
8518
|
if (this.stream.active) {
|
|
@@ -8955,6 +8961,7 @@ var chsRecord = (function (Data, chsTemplates, jspsych) {
|
|
|
8955
8961
|
minVolume = 0.1;
|
|
8956
8962
|
micChecked = false;
|
|
8957
8963
|
processorNode = null;
|
|
8964
|
+
mimeType = "video/webm";
|
|
8958
8965
|
trial(display_element, trial) {
|
|
8959
8966
|
this.display_el = display_element;
|
|
8960
8967
|
navigator.mediaDevices.ondevicechange = this.onDeviceChange;
|
|
@@ -9109,7 +9116,12 @@ var chsRecord = (function (Data, chsTemplates, jspsych) {
|
|
|
9109
9116
|
return { cameras: unique_cameras, mics: unique_mics };
|
|
9110
9117
|
};
|
|
9111
9118
|
initializeAndCreateRecorder = (stream, opts) => {
|
|
9112
|
-
this.
|
|
9119
|
+
this.mimeType = this.getCompatibleMimeType() || this.mimeType;
|
|
9120
|
+
const recorder_options = {
|
|
9121
|
+
...opts,
|
|
9122
|
+
mimeType: this.mimeType
|
|
9123
|
+
};
|
|
9124
|
+
this.jsPsych.pluginAPI.initializeCameraRecorder(stream, recorder_options);
|
|
9113
9125
|
this.recorder = new Recorder(this.jsPsych);
|
|
9114
9126
|
};
|
|
9115
9127
|
checkMic = async (minVol = this.minVolume) => {
|
|
@@ -9249,6 +9261,20 @@ var chsRecord = (function (Data, chsTemplates, jspsych) {
|
|
|
9249
9261
|
next_button_el.classList.remove(`${html_params.step_complete_class}`);
|
|
9250
9262
|
}
|
|
9251
9263
|
};
|
|
9264
|
+
getCompatibleMimeType() {
|
|
9265
|
+
const mime_types = [
|
|
9266
|
+
"video/webm;codecs=vp9,opus",
|
|
9267
|
+
"video/webm;codecs=vp8,opus"
|
|
9268
|
+
];
|
|
9269
|
+
let mime_type_index = 0;
|
|
9270
|
+
while (mime_type_index < mime_types.length) {
|
|
9271
|
+
if (MediaRecorder.isTypeSupported(mime_types[mime_type_index])) {
|
|
9272
|
+
return mime_types[mime_type_index];
|
|
9273
|
+
}
|
|
9274
|
+
mime_type_index++;
|
|
9275
|
+
}
|
|
9276
|
+
return null;
|
|
9277
|
+
}
|
|
9252
9278
|
}
|
|
9253
9279
|
|
|
9254
9280
|
var index = {
|
|
@@ -9262,4 +9288,4 @@ var chsRecord = (function (Data, chsTemplates, jspsych) {
|
|
|
9262
9288
|
return index;
|
|
9263
9289
|
|
|
9264
9290
|
})(chsData, chsTemplates, jsPsychModule);
|
|
9265
|
-
//# sourceMappingURL=https://unpkg.com/@lookit/record@3.0.
|
|
9291
|
+
//# sourceMappingURL=https://unpkg.com/@lookit/record@3.0.1/dist/index.browser.js.map
|