@lookit/record 3.0.1 → 4.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/dist/index.browser.js +68 -31
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.min.js +12 -12
- package/dist/index.browser.min.js.map +1 -1
- package/dist/index.cjs +67 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +25 -3
- package/dist/index.js +67 -30
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/consentVideo.spec.ts +38 -11
- package/src/consentVideo.ts +75 -18
- package/src/errors.ts +7 -27
- package/src/recorder.spec.ts +120 -0
- package/src/recorder.ts +28 -4
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: "
|
|
35
|
+
version: "4.0.0",
|
|
36
36
|
description: "Recording extensions and plugins for CHS studies.",
|
|
37
37
|
homepage: "https://github.com/lookit/lookit-jspsych#readme",
|
|
38
38
|
bugs: {
|
|
@@ -74,7 +74,7 @@ var chsRecord = (function (Data, chsTemplates, jspsych) {
|
|
|
74
74
|
},
|
|
75
75
|
peerDependencies: {
|
|
76
76
|
"@lookit/data": "^0.2.0",
|
|
77
|
-
"@lookit/templates": "^2.
|
|
77
|
+
"@lookit/templates": "^2.1.0",
|
|
78
78
|
jspsych: "^8.0.3"
|
|
79
79
|
}
|
|
80
80
|
};
|
|
@@ -167,21 +167,10 @@ var chsRecord = (function (Data, chsTemplates, jspsych) {
|
|
|
167
167
|
this.name = "CreateURLError";
|
|
168
168
|
}
|
|
169
169
|
}
|
|
170
|
-
class
|
|
171
|
-
constructor() {
|
|
172
|
-
super("
|
|
173
|
-
this.name = "
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
class ButtonNotFoundError extends Error {
|
|
177
|
-
constructor(id) {
|
|
178
|
-
super(`"${id}" button not found.`);
|
|
179
|
-
this.name = "ButtonNotFoundError";
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
class ImageNotFoundError extends Error {
|
|
183
|
-
constructor(id) {
|
|
184
|
-
super(`"${id}" image not found.`);
|
|
170
|
+
class ElementNotFoundError extends Error {
|
|
171
|
+
constructor(id, tag) {
|
|
172
|
+
super(`"${id}" ${tag} not found.`);
|
|
173
|
+
this.name = "ElementNotFoundError";
|
|
185
174
|
}
|
|
186
175
|
}
|
|
187
176
|
|
|
@@ -8580,9 +8569,9 @@ var chsRecord = (function (Data, chsTemplates, jspsych) {
|
|
|
8580
8569
|
this.recorder.stop();
|
|
8581
8570
|
this.stream.getTracks().map((t) => t.stop());
|
|
8582
8571
|
}
|
|
8583
|
-
stop() {
|
|
8572
|
+
stop(maintain_container_size = false) {
|
|
8573
|
+
this.clearWebcamFeed(maintain_container_size);
|
|
8584
8574
|
this.stopTracks();
|
|
8585
|
-
this.clearWebcamFeed();
|
|
8586
8575
|
if (!this.stopPromise) {
|
|
8587
8576
|
throw new NoStopPromiseError();
|
|
8588
8577
|
}
|
|
@@ -8627,11 +8616,20 @@ var chsRecord = (function (Data, chsTemplates, jspsych) {
|
|
|
8627
8616
|
link.click();
|
|
8628
8617
|
}
|
|
8629
8618
|
}
|
|
8630
|
-
clearWebcamFeed() {
|
|
8619
|
+
clearWebcamFeed(maintain_container_size) {
|
|
8631
8620
|
const webcam_feed_element = document.querySelector(
|
|
8632
8621
|
`#${this.webcam_element_id}`
|
|
8633
8622
|
);
|
|
8634
8623
|
if (webcam_feed_element) {
|
|
8624
|
+
if (maintain_container_size) {
|
|
8625
|
+
const parent_div = webcam_feed_element.parentElement;
|
|
8626
|
+
if (parent_div) {
|
|
8627
|
+
const width = webcam_feed_element.offsetWidth;
|
|
8628
|
+
const height = webcam_feed_element.offsetHeight;
|
|
8629
|
+
parent_div.style.height = `${height}px`;
|
|
8630
|
+
parent_div.style.width = `${width}px`;
|
|
8631
|
+
}
|
|
8632
|
+
}
|
|
8635
8633
|
webcam_feed_element.remove();
|
|
8636
8634
|
}
|
|
8637
8635
|
}
|
|
@@ -8706,6 +8704,11 @@ var chsRecord = (function (Data, chsTemplates, jspsych) {
|
|
|
8706
8704
|
static info = info$3;
|
|
8707
8705
|
recorder;
|
|
8708
8706
|
video_container_id = "lookit-jspsych-video-container";
|
|
8707
|
+
msg_container_id = "lookit-jspsych-video-msg-container";
|
|
8708
|
+
uploadingMsg = null;
|
|
8709
|
+
startingMsg = null;
|
|
8710
|
+
recordingMsg = null;
|
|
8711
|
+
notRecordingMsg = null;
|
|
8709
8712
|
trial(display, trial) {
|
|
8710
8713
|
const consentVideo = chsTemplates.consentVideo(trial);
|
|
8711
8714
|
display.insertAdjacentHTML("afterbegin", consentVideo);
|
|
@@ -8714,13 +8717,25 @@ var chsRecord = (function (Data, chsTemplates, jspsych) {
|
|
|
8714
8717
|
this.stopButton(display);
|
|
8715
8718
|
this.playButton(display);
|
|
8716
8719
|
this.nextButton(display);
|
|
8720
|
+
this.uploadingMsg = chsTemplates.translateString(
|
|
8721
|
+
"exp-lookit-video-consent.Stopping-and-uploading"
|
|
8722
|
+
);
|
|
8723
|
+
this.startingMsg = chsTemplates.translateString(
|
|
8724
|
+
"exp-lookit-video-consent.Starting-recorder"
|
|
8725
|
+
);
|
|
8726
|
+
this.recordingMsg = chsTemplates.translateString(
|
|
8727
|
+
"exp-lookit-video-consent.Recording"
|
|
8728
|
+
);
|
|
8729
|
+
this.notRecordingMsg = chsTemplates.translateString(
|
|
8730
|
+
"exp-lookit-video-consent.Not-recording"
|
|
8731
|
+
);
|
|
8717
8732
|
}
|
|
8718
8733
|
getVideoContainer(display) {
|
|
8719
8734
|
const videoContainer = display.querySelector(
|
|
8720
8735
|
`div#${this.video_container_id}`
|
|
8721
8736
|
);
|
|
8722
8737
|
if (!videoContainer) {
|
|
8723
|
-
throw new
|
|
8738
|
+
throw new ElementNotFoundError(this.video_container_id, "div");
|
|
8724
8739
|
}
|
|
8725
8740
|
return videoContainer;
|
|
8726
8741
|
}
|
|
@@ -8731,14 +8746,31 @@ var chsRecord = (function (Data, chsTemplates, jspsych) {
|
|
|
8731
8746
|
}
|
|
8732
8747
|
playbackFeed(display) {
|
|
8733
8748
|
const videoContainer = this.getVideoContainer(display);
|
|
8734
|
-
this.recorder.insertPlaybackFeed(
|
|
8749
|
+
this.recorder.insertPlaybackFeed(
|
|
8750
|
+
videoContainer,
|
|
8751
|
+
this.onPlaybackEnded(display)
|
|
8752
|
+
);
|
|
8735
8753
|
}
|
|
8736
|
-
|
|
8754
|
+
getMessageContainer(display) {
|
|
8755
|
+
const msgContainer = display.querySelector(
|
|
8756
|
+
`div#${this.msg_container_id}`
|
|
8757
|
+
);
|
|
8758
|
+
if (!msgContainer) {
|
|
8759
|
+
throw new ElementNotFoundError(this.msg_container_id, "div");
|
|
8760
|
+
}
|
|
8761
|
+
return msgContainer;
|
|
8762
|
+
}
|
|
8763
|
+
addMessage(display, message) {
|
|
8764
|
+
const msgContainer = this.getMessageContainer(display);
|
|
8765
|
+
msgContainer.innerHTML = message;
|
|
8766
|
+
}
|
|
8767
|
+
onPlaybackEnded(display) {
|
|
8737
8768
|
return () => {
|
|
8738
8769
|
const next = this.getButton(display, "next");
|
|
8739
8770
|
const play = this.getButton(display, "play");
|
|
8740
8771
|
const record = this.getButton(display, "record");
|
|
8741
8772
|
this.recordFeed(display);
|
|
8773
|
+
this.addMessage(display, this.notRecordingMsg);
|
|
8742
8774
|
next.disabled = false;
|
|
8743
8775
|
play.disabled = false;
|
|
8744
8776
|
record.disabled = false;
|
|
@@ -8747,14 +8779,14 @@ var chsRecord = (function (Data, chsTemplates, jspsych) {
|
|
|
8747
8779
|
getButton(display, id) {
|
|
8748
8780
|
const btn = display.querySelector(`button#${id}`);
|
|
8749
8781
|
if (!btn) {
|
|
8750
|
-
throw new
|
|
8782
|
+
throw new ElementNotFoundError(id, "button");
|
|
8751
8783
|
}
|
|
8752
8784
|
return btn;
|
|
8753
8785
|
}
|
|
8754
8786
|
getImg(display, id) {
|
|
8755
8787
|
const img = display.querySelector(`img#${id}`);
|
|
8756
8788
|
if (!img) {
|
|
8757
|
-
throw new
|
|
8789
|
+
throw new ElementNotFoundError(id, "img");
|
|
8758
8790
|
}
|
|
8759
8791
|
return img;
|
|
8760
8792
|
}
|
|
@@ -8764,12 +8796,14 @@ var chsRecord = (function (Data, chsTemplates, jspsych) {
|
|
|
8764
8796
|
const play = this.getButton(display, "play");
|
|
8765
8797
|
const next = this.getButton(display, "next");
|
|
8766
8798
|
record.addEventListener("click", async () => {
|
|
8799
|
+
this.addMessage(display, this.startingMsg);
|
|
8767
8800
|
record.disabled = true;
|
|
8768
|
-
stop.disabled = false;
|
|
8769
8801
|
play.disabled = true;
|
|
8770
8802
|
next.disabled = true;
|
|
8771
|
-
this.getImg(display, "record-icon").style.visibility = "visible";
|
|
8772
8803
|
await this.recorder.start(true, VideoConsentPlugin.info.name);
|
|
8804
|
+
this.getImg(display, "record-icon").style.visibility = "visible";
|
|
8805
|
+
this.addMessage(display, this.recordingMsg);
|
|
8806
|
+
stop.disabled = false;
|
|
8773
8807
|
});
|
|
8774
8808
|
}
|
|
8775
8809
|
playButton(display) {
|
|
@@ -8787,11 +8821,14 @@ var chsRecord = (function (Data, chsTemplates, jspsych) {
|
|
|
8787
8821
|
const play = this.getButton(display, "play");
|
|
8788
8822
|
stop.addEventListener("click", async () => {
|
|
8789
8823
|
stop.disabled = true;
|
|
8790
|
-
|
|
8791
|
-
|
|
8792
|
-
await this.recorder.stop();
|
|
8824
|
+
this.addMessage(display, this.uploadingMsg);
|
|
8825
|
+
await this.recorder.stop(true);
|
|
8793
8826
|
this.recorder.reset();
|
|
8794
8827
|
this.recordFeed(display);
|
|
8828
|
+
this.getImg(display, "record-icon").style.visibility = "hidden";
|
|
8829
|
+
this.addMessage(display, this.notRecordingMsg);
|
|
8830
|
+
play.disabled = false;
|
|
8831
|
+
record.disabled = false;
|
|
8795
8832
|
});
|
|
8796
8833
|
}
|
|
8797
8834
|
nextButton(display) {
|
|
@@ -9288,4 +9325,4 @@ var chsRecord = (function (Data, chsTemplates, jspsych) {
|
|
|
9288
9325
|
return index;
|
|
9289
9326
|
|
|
9290
9327
|
})(chsData, chsTemplates, jsPsychModule);
|
|
9291
|
-
//# sourceMappingURL=https://unpkg.com/@lookit/record@
|
|
9328
|
+
//# sourceMappingURL=https://unpkg.com/@lookit/record@4.0.0/dist/index.browser.js.map
|