@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/dist/index.d.ts
CHANGED
|
@@ -553,6 +553,7 @@ declare class VideoConfigPlugin implements JsPsychPlugin<Info> {
|
|
|
553
553
|
private minVolume;
|
|
554
554
|
private micChecked;
|
|
555
555
|
private processorNode;
|
|
556
|
+
private mimeType;
|
|
556
557
|
/**
|
|
557
558
|
* Constructor for video config plugin.
|
|
558
559
|
*
|
|
@@ -663,6 +664,8 @@ declare class VideoConfigPlugin implements JsPsychPlugin<Info> {
|
|
|
663
664
|
* @param stream - Media stream returned from getUserMedia that should be used
|
|
664
665
|
* to set up the jsPsych recorder.
|
|
665
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.
|
|
666
669
|
*/
|
|
667
670
|
initializeAndCreateRecorder: (stream: MediaStream, opts?: MediaRecorderOptions) => void;
|
|
668
671
|
/**
|
|
@@ -753,6 +756,20 @@ declare class VideoConfigPlugin implements JsPsychPlugin<Info> {
|
|
|
753
756
|
* button.
|
|
754
757
|
*/
|
|
755
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;
|
|
756
773
|
}
|
|
757
774
|
|
|
758
775
|
declare const _default: {
|
package/dist/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import Handlebars from 'handlebars';
|
|
|
6
6
|
|
|
7
7
|
var _package = {
|
|
8
8
|
name: "@lookit/record",
|
|
9
|
-
version: "3.0.
|
|
9
|
+
version: "3.0.1",
|
|
10
10
|
description: "Recording extensions and plugins for CHS studies.",
|
|
11
11
|
homepage: "https://github.com/lookit/lookit-jspsych#readme",
|
|
12
12
|
bugs: {
|
|
@@ -175,8 +175,10 @@ class Recorder {
|
|
|
175
175
|
this.blobs = [];
|
|
176
176
|
this.localDownload = "false"?.toLowerCase() === "true";
|
|
177
177
|
this.webcam_element_id = "lookit-jspsych-webcam";
|
|
178
|
+
this.mimeType = "video/webm";
|
|
178
179
|
this.streamClone = this.stream.clone();
|
|
179
180
|
autoBind(this);
|
|
181
|
+
this.mimeType = this.recorder?.mimeType || this.mimeType;
|
|
180
182
|
}
|
|
181
183
|
get recorder() {
|
|
182
184
|
return this.jsPsych.pluginAPI.getCameraRecorder() || this.jsPsych.pluginAPI.getMicrophoneRecorder();
|
|
@@ -194,7 +196,11 @@ class Recorder {
|
|
|
194
196
|
this._s3 = value;
|
|
195
197
|
}
|
|
196
198
|
initializeRecorder(stream, opts) {
|
|
197
|
-
|
|
199
|
+
const recorder_options = {
|
|
200
|
+
...opts,
|
|
201
|
+
mimeType: this.mimeType
|
|
202
|
+
};
|
|
203
|
+
this.jsPsych.pluginAPI.initializeCameraRecorder(stream, recorder_options);
|
|
198
204
|
}
|
|
199
205
|
reset() {
|
|
200
206
|
if (this.stream.active) {
|
|
@@ -638,6 +644,7 @@ class VideoConfigPlugin {
|
|
|
638
644
|
this.minVolume = 0.1;
|
|
639
645
|
this.micChecked = false;
|
|
640
646
|
this.processorNode = null;
|
|
647
|
+
this.mimeType = "video/webm";
|
|
641
648
|
this.addHtmlContent = (trial) => {
|
|
642
649
|
this.display_el.innerHTML = chsTemplates.videoConfig(trial, html_params);
|
|
643
650
|
};
|
|
@@ -780,7 +787,12 @@ class VideoConfigPlugin {
|
|
|
780
787
|
return { cameras: unique_cameras, mics: unique_mics };
|
|
781
788
|
};
|
|
782
789
|
this.initializeAndCreateRecorder = (stream, opts) => {
|
|
783
|
-
this.
|
|
790
|
+
this.mimeType = this.getCompatibleMimeType() || this.mimeType;
|
|
791
|
+
const recorder_options = {
|
|
792
|
+
...opts,
|
|
793
|
+
mimeType: this.mimeType
|
|
794
|
+
};
|
|
795
|
+
this.jsPsych.pluginAPI.initializeCameraRecorder(stream, recorder_options);
|
|
784
796
|
this.recorder = new Recorder(this.jsPsych);
|
|
785
797
|
};
|
|
786
798
|
this.checkMic = async (minVol = this.minVolume) => {
|
|
@@ -933,6 +945,20 @@ class VideoConfigPlugin {
|
|
|
933
945
|
};
|
|
934
946
|
});
|
|
935
947
|
}
|
|
948
|
+
getCompatibleMimeType() {
|
|
949
|
+
const mime_types = [
|
|
950
|
+
"video/webm;codecs=vp9,opus",
|
|
951
|
+
"video/webm;codecs=vp8,opus"
|
|
952
|
+
];
|
|
953
|
+
let mime_type_index = 0;
|
|
954
|
+
while (mime_type_index < mime_types.length) {
|
|
955
|
+
if (MediaRecorder.isTypeSupported(mime_types[mime_type_index])) {
|
|
956
|
+
return mime_types[mime_type_index];
|
|
957
|
+
}
|
|
958
|
+
mime_type_index++;
|
|
959
|
+
}
|
|
960
|
+
return null;
|
|
961
|
+
}
|
|
936
962
|
}
|
|
937
963
|
VideoConfigPlugin.info = info;
|
|
938
964
|
|