@lookit/record 4.0.0 → 4.1.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 +125 -6
- package/dist/index.browser.js +70 -12
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.min.js +16 -16
- package/dist/index.browser.min.js.map +1 -1
- package/dist/index.cjs +69 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +104 -9
- package/dist/index.js +69 -11
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/consentVideo.spec.ts +0 -1
- package/src/consentVideo.ts +5 -1
- package/src/index.spec.ts +387 -12
- package/src/recorder.spec.ts +50 -6
- package/src/recorder.ts +9 -1
- package/src/start.ts +7 -1
- package/src/stop.ts +41 -7
- package/src/trial.ts +97 -11
package/README.md
CHANGED
|
@@ -356,9 +356,21 @@ To use the CHS trial recording extension, you need to:
|
|
|
356
356
|
|
|
357
357
|
### Parameters
|
|
358
358
|
|
|
359
|
-
|
|
359
|
+
**`wait_for_upload_message` [`null` or HTML string | `null` ]**
|
|
360
|
+
|
|
361
|
+
This parameter determines what content should be displayed while the trial
|
|
362
|
+
recording is uploading. If `null` (the default), then the message 'uploading
|
|
363
|
+
video, please wait...' (or appropriate translation based on `locale`) will be
|
|
364
|
+
displayed. Otherwise this parameter can be set to a custom string and can
|
|
365
|
+
contain HTML markup. If you want to embed images/video/audio in this HTML
|
|
366
|
+
string, be sure to preload the media files with the `preload` plugin and
|
|
367
|
+
[manual preloading](https://www.jspsych.org/latest/overview/media-preloading/#manual-preloading).
|
|
368
|
+
Use a blank string (`""`) for no message/content. If a value is provided then
|
|
369
|
+
the `locale` parameter will be ignored.
|
|
360
370
|
|
|
361
|
-
###
|
|
371
|
+
### Examples
|
|
372
|
+
|
|
373
|
+
**Basic usage**
|
|
362
374
|
|
|
363
375
|
To record a single trial, you will have to first load the extension in
|
|
364
376
|
`initJsPsych`.
|
|
@@ -375,7 +387,7 @@ record any trial you design.
|
|
|
375
387
|
|
|
376
388
|
```javascript
|
|
377
389
|
const trialRec = {
|
|
378
|
-
// ... Other trial
|
|
390
|
+
// ... Other trial parameters ...
|
|
379
391
|
extensions: [{ type: chsRecord.TrialRecordExtension }],
|
|
380
392
|
};
|
|
381
393
|
```
|
|
@@ -386,6 +398,60 @@ Finally, insert the trials into the timeline.
|
|
|
386
398
|
jsPsych.run([videoConfig, trialRec]);
|
|
387
399
|
```
|
|
388
400
|
|
|
401
|
+
**Setting parameters**
|
|
402
|
+
|
|
403
|
+
You can set the trial extension parameters when you load the extension with
|
|
404
|
+
`initJsPsych`.
|
|
405
|
+
|
|
406
|
+
In the example below, the default "uploading video, please wait..." message will
|
|
407
|
+
be displayed in French while a trial recording is uploading at the end of the
|
|
408
|
+
trial.
|
|
409
|
+
|
|
410
|
+
```javascript
|
|
411
|
+
const jsPsych = initJsPsych({
|
|
412
|
+
extensions: [
|
|
413
|
+
{
|
|
414
|
+
type: chsRecord.TrialRecordExtension,
|
|
415
|
+
params: { locale: "fr" },
|
|
416
|
+
},
|
|
417
|
+
],
|
|
418
|
+
});
|
|
419
|
+
```
|
|
420
|
+
|
|
421
|
+
And in this example, the custom message "Please wait!" will be displayed while
|
|
422
|
+
the trial recording is uploading. You can include any HTML-formatted content in
|
|
423
|
+
this string, which means you can display images, videos, animations etc.
|
|
424
|
+
|
|
425
|
+
```javascript
|
|
426
|
+
const jsPsych = initJsPsych({
|
|
427
|
+
extensions: [
|
|
428
|
+
{
|
|
429
|
+
type: chsRecord.TrialRecordExtension,
|
|
430
|
+
params: { wait_for_upload_message: "<div>Please wait!</div>" },
|
|
431
|
+
},
|
|
432
|
+
],
|
|
433
|
+
});
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
You can also set the parameters within individual trials. This will override any
|
|
437
|
+
parameters set during the extension initialization (in `initJsPsych`), which can
|
|
438
|
+
be useful if you want to change the parameter values during the experiment. In
|
|
439
|
+
this example, the `wait_for_upload_message` is set to an empty string, which
|
|
440
|
+
will prevent the default "uploading video, please wait..." message from
|
|
441
|
+
appearing after the trial finishes.
|
|
442
|
+
|
|
443
|
+
```javascript
|
|
444
|
+
const trialRec = {
|
|
445
|
+
// ... Other trial parameters ...
|
|
446
|
+
extensions: [
|
|
447
|
+
{
|
|
448
|
+
type: chsRecord.TrialRecordExtension,
|
|
449
|
+
params: { wait_for_upload_message: "" },
|
|
450
|
+
},
|
|
451
|
+
],
|
|
452
|
+
};
|
|
453
|
+
```
|
|
454
|
+
|
|
389
455
|
## Session Recording
|
|
390
456
|
|
|
391
457
|
You might prefer to record across multiple trials in a study session. This can
|
|
@@ -425,12 +491,37 @@ The plugin to stop session recording is called `chsRecord.StopRecordPlugin`.
|
|
|
425
491
|
const stopRec = { type: chsRecord.StopRecordPlugin };
|
|
426
492
|
```
|
|
427
493
|
|
|
494
|
+
When the trial starts, by default, this plugin will display "uploading video,
|
|
495
|
+
please wait...", or the appropriate translation based on the `locale` parameter.
|
|
496
|
+
This message can be customized using the `wait_for_upload_message` parameter,
|
|
497
|
+
which is the HTML-formatted string to be displayed while the session recording
|
|
498
|
+
is uploading.
|
|
499
|
+
|
|
500
|
+
```javascript
|
|
501
|
+
const stopRec = {
|
|
502
|
+
type: chsRecord.StopRecordPlugin,
|
|
503
|
+
wait_for_upload_message:
|
|
504
|
+
"<p style='color:red;'>Please wait while we upload your video.</p>",
|
|
505
|
+
};
|
|
506
|
+
```
|
|
507
|
+
|
|
428
508
|
#### Parameters
|
|
429
509
|
|
|
430
|
-
|
|
431
|
-
plugins.
|
|
510
|
+
**`wait_for_upload_message` [`null` or HTML string | `null` ]**
|
|
432
511
|
|
|
433
|
-
|
|
512
|
+
This parameter determines what content should be displayed while the session
|
|
513
|
+
recording is uploading. If `null` (the default), then the message 'uploading
|
|
514
|
+
video, please wait...' (or appropriate translation based on `locale`) will be
|
|
515
|
+
displayed. Otherwise this parameter can be set to a custom string and can
|
|
516
|
+
contain HTML markup. If you want to embed images/video/audio in this HTML
|
|
517
|
+
string, be sure to preload the media files with the `preload` plugin and
|
|
518
|
+
[manual preloading](https://www.jspsych.org/latest/overview/media-preloading/#manual-preloading).
|
|
519
|
+
Use a blank string (`""`) for no message/content. If a value is provided then
|
|
520
|
+
the `locale` parameter will be ignored.
|
|
521
|
+
|
|
522
|
+
### Examples
|
|
523
|
+
|
|
524
|
+
**Basic usage**
|
|
434
525
|
|
|
435
526
|
First, make sure that you've added a video config trial to your experiment
|
|
436
527
|
timeline. Then, create your start and stop recording trials:
|
|
@@ -476,3 +567,31 @@ jsPsych.run([
|
|
|
476
567
|
stopRec,
|
|
477
568
|
]);
|
|
478
569
|
```
|
|
570
|
+
|
|
571
|
+
**Setting parameters**
|
|
572
|
+
|
|
573
|
+
By default, the stop session recording plugin will display "uploading video,
|
|
574
|
+
please wait..." while the session recording is uploading. You can set the
|
|
575
|
+
`locale` parameter value to translate this message to another language. For
|
|
576
|
+
example, the trial below will display the Brazilian Portuguese translation of
|
|
577
|
+
this message. If the locale string does not match any of the translation codes
|
|
578
|
+
that we support, then the message will be displayed in English.
|
|
579
|
+
|
|
580
|
+
```javascript
|
|
581
|
+
const stopRec = {
|
|
582
|
+
type: chsRecord.StopRecordPlugin,
|
|
583
|
+
locale: "pt-br",
|
|
584
|
+
};
|
|
585
|
+
```
|
|
586
|
+
|
|
587
|
+
You can also set custom content to be displayed while the session recording file
|
|
588
|
+
is uploading. The value must be a string. It can include HTML-formatted content,
|
|
589
|
+
which means that you can embed audio, video, images etc. (be sure to preload any
|
|
590
|
+
media files!).
|
|
591
|
+
|
|
592
|
+
```javascript
|
|
593
|
+
const stopRec = {
|
|
594
|
+
type: chsRecord.StopRecordPlugin,
|
|
595
|
+
wait_for_upload_message: "<p style='color:red;'>Hang on a sec!</p>",
|
|
596
|
+
};
|
|
597
|
+
```
|
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: "4.
|
|
35
|
+
version: "4.1.0",
|
|
36
36
|
description: "Recording extensions and plugins for CHS studies.",
|
|
37
37
|
homepage: "https://github.com/lookit/lookit-jspsych#readme",
|
|
38
38
|
bugs: {
|
|
@@ -8599,6 +8599,7 @@ var chsRecord = (function (Data, chsTemplates, jspsych) {
|
|
|
8599
8599
|
} else {
|
|
8600
8600
|
await this.s3.completeUpload();
|
|
8601
8601
|
}
|
|
8602
|
+
this.reset();
|
|
8602
8603
|
resolve();
|
|
8603
8604
|
};
|
|
8604
8605
|
}
|
|
@@ -8693,6 +8694,11 @@ var chsRecord = (function (Data, chsTemplates, jspsych) {
|
|
|
8693
8694
|
prompt_only_adults: { type: jspsych.ParameterType.BOOL, default: false },
|
|
8694
8695
|
consent_statement_text: { type: jspsych.ParameterType.STRING, default: "" },
|
|
8695
8696
|
omit_injury_phrase: { type: jspsych.ParameterType.BOOL, default: false }
|
|
8697
|
+
},
|
|
8698
|
+
data: {
|
|
8699
|
+
chs_type: {
|
|
8700
|
+
type: jspsych.ParameterType.STRING
|
|
8701
|
+
}
|
|
8696
8702
|
}
|
|
8697
8703
|
};
|
|
8698
8704
|
class VideoConsentPlugin {
|
|
@@ -8823,7 +8829,6 @@ var chsRecord = (function (Data, chsTemplates, jspsych) {
|
|
|
8823
8829
|
stop.disabled = true;
|
|
8824
8830
|
this.addMessage(display, this.uploadingMsg);
|
|
8825
8831
|
await this.recorder.stop(true);
|
|
8826
|
-
this.recorder.reset();
|
|
8827
8832
|
this.recordFeed(display);
|
|
8828
8833
|
this.getImg(display, "record-icon").style.visibility = "hidden";
|
|
8829
8834
|
this.addMessage(display, this.notRecordingMsg);
|
|
@@ -8846,7 +8851,12 @@ var chsRecord = (function (Data, chsTemplates, jspsych) {
|
|
|
8846
8851
|
}
|
|
8847
8852
|
}
|
|
8848
8853
|
|
|
8849
|
-
const info$2 = {
|
|
8854
|
+
const info$2 = {
|
|
8855
|
+
name: "start-record-plugin",
|
|
8856
|
+
version: _package.version,
|
|
8857
|
+
parameters: {},
|
|
8858
|
+
data: {}
|
|
8859
|
+
};
|
|
8850
8860
|
class StartRecordPlugin {
|
|
8851
8861
|
constructor(jsPsych) {
|
|
8852
8862
|
this.jsPsych = jsPsych;
|
|
@@ -8868,9 +8878,18 @@ var chsRecord = (function (Data, chsTemplates, jspsych) {
|
|
|
8868
8878
|
|
|
8869
8879
|
const info$1 = {
|
|
8870
8880
|
name: "stop-record-plugin",
|
|
8881
|
+
version: _package.version,
|
|
8871
8882
|
parameters: {
|
|
8872
|
-
|
|
8873
|
-
|
|
8883
|
+
wait_for_upload_message: {
|
|
8884
|
+
type: jspsych.ParameterType.HTML_STRING,
|
|
8885
|
+
default: null
|
|
8886
|
+
},
|
|
8887
|
+
locale: {
|
|
8888
|
+
type: jspsych.ParameterType.STRING,
|
|
8889
|
+
default: "en-us"
|
|
8890
|
+
}
|
|
8891
|
+
},
|
|
8892
|
+
data: {}
|
|
8874
8893
|
};
|
|
8875
8894
|
class StopRecordPlugin {
|
|
8876
8895
|
constructor(jsPsych) {
|
|
@@ -8884,11 +8903,17 @@ var chsRecord = (function (Data, chsTemplates, jspsych) {
|
|
|
8884
8903
|
static info = info$1;
|
|
8885
8904
|
recorder;
|
|
8886
8905
|
trial(display_element, trial) {
|
|
8887
|
-
|
|
8906
|
+
if (trial.wait_for_upload_message == null) {
|
|
8907
|
+
display_element.innerHTML = chsTemplates.uploadingVideo(trial);
|
|
8908
|
+
} else {
|
|
8909
|
+
display_element.innerHTML = trial.wait_for_upload_message;
|
|
8910
|
+
}
|
|
8888
8911
|
this.recorder.stop().then(() => {
|
|
8889
8912
|
window.chs.sessionRecorder = null;
|
|
8890
8913
|
display_element.innerHTML = "";
|
|
8891
8914
|
this.jsPsych.finishTrial();
|
|
8915
|
+
}).catch((err) => {
|
|
8916
|
+
console.error("StopRecordPlugin: recorder stop/upload failed.", err);
|
|
8892
8917
|
});
|
|
8893
8918
|
}
|
|
8894
8919
|
}
|
|
@@ -8899,21 +8924,54 @@ var chsRecord = (function (Data, chsTemplates, jspsych) {
|
|
|
8899
8924
|
autoBind(this);
|
|
8900
8925
|
}
|
|
8901
8926
|
static info = {
|
|
8902
|
-
name: "chs-trial-record-extension"
|
|
8927
|
+
name: "chs-trial-record-extension",
|
|
8928
|
+
version: _package.version,
|
|
8929
|
+
data: {}
|
|
8903
8930
|
};
|
|
8904
8931
|
recorder;
|
|
8905
8932
|
pluginName;
|
|
8906
|
-
|
|
8933
|
+
uploadMsg = null;
|
|
8934
|
+
locale = "en-us";
|
|
8935
|
+
async initialize(params) {
|
|
8936
|
+
await new Promise((resolve) => {
|
|
8937
|
+
this.uploadMsg = params?.wait_for_upload_message ? params.wait_for_upload_message : null;
|
|
8938
|
+
this.locale = params?.locale ? params.locale : "en-us";
|
|
8939
|
+
console.log(this.uploadMsg);
|
|
8940
|
+
console.log(this.locale);
|
|
8941
|
+
resolve();
|
|
8942
|
+
});
|
|
8907
8943
|
}
|
|
8908
|
-
on_start() {
|
|
8944
|
+
on_start(startParams) {
|
|
8945
|
+
if (startParams?.wait_for_upload_message) {
|
|
8946
|
+
this.uploadMsg = startParams.wait_for_upload_message;
|
|
8947
|
+
}
|
|
8948
|
+
if (startParams?.locale) {
|
|
8949
|
+
this.locale = startParams.locale;
|
|
8950
|
+
}
|
|
8951
|
+
console.log(this.uploadMsg);
|
|
8952
|
+
console.log(this.locale);
|
|
8909
8953
|
this.recorder = new Recorder(this.jsPsych);
|
|
8910
8954
|
}
|
|
8911
8955
|
on_load() {
|
|
8912
8956
|
this.pluginName = this.getCurrentPluginName();
|
|
8913
8957
|
this.recorder?.start(false, `${this.pluginName}`);
|
|
8914
8958
|
}
|
|
8915
|
-
on_finish() {
|
|
8916
|
-
this.
|
|
8959
|
+
async on_finish() {
|
|
8960
|
+
const displayEl = this.jsPsych.getDisplayElement();
|
|
8961
|
+
if (this.uploadMsg == null) {
|
|
8962
|
+
displayEl.innerHTML = chsTemplates.uploadingVideo({
|
|
8963
|
+
type: this.jsPsych.getCurrentTrial().type,
|
|
8964
|
+
locale: this.locale
|
|
8965
|
+
});
|
|
8966
|
+
} else {
|
|
8967
|
+
displayEl.innerHTML = this.uploadMsg;
|
|
8968
|
+
}
|
|
8969
|
+
try {
|
|
8970
|
+
await this.recorder?.stop();
|
|
8971
|
+
displayEl.innerHTML = "";
|
|
8972
|
+
} catch (err) {
|
|
8973
|
+
console.error("TrialRecordExtension: recorder stop/upload failed.", err);
|
|
8974
|
+
}
|
|
8917
8975
|
return {};
|
|
8918
8976
|
}
|
|
8919
8977
|
getCurrentPluginName() {
|
|
@@ -9325,4 +9383,4 @@ var chsRecord = (function (Data, chsTemplates, jspsych) {
|
|
|
9325
9383
|
return index;
|
|
9326
9384
|
|
|
9327
9385
|
})(chsData, chsTemplates, jsPsychModule);
|
|
9328
|
-
//# sourceMappingURL=https://unpkg.com/@lookit/record@4.
|
|
9386
|
+
//# sourceMappingURL=https://unpkg.com/@lookit/record@4.1.0/dist/index.browser.js.map
|