jspsych 8.2.1 → 8.2.2
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 +28 -3
- package/dist/index.browser.js.map +1 -1
- package/dist/index.browser.min.js +6 -6
- package/dist/index.browser.min.js.map +1 -1
- package/dist/index.cjs +27 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +27 -2
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/modules/plugin-api/MediaAPI.ts +28 -1
package/dist/index.d.ts
CHANGED
|
@@ -666,6 +666,8 @@ declare class MediaAPI {
|
|
|
666
666
|
private camera_stream;
|
|
667
667
|
private camera_recorder;
|
|
668
668
|
initializeCameraRecorder(stream: MediaStream, opts?: MediaRecorderOptions): void;
|
|
669
|
+
/** returns a compatible mimetype string, or null if none from the array are supported. */
|
|
670
|
+
private getCompatibleMimeType;
|
|
669
671
|
getCameraStream(): MediaStream;
|
|
670
672
|
getCameraRecorder(): MediaRecorder;
|
|
671
673
|
}
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import autoBind from 'auto-bind';
|
|
|
2
2
|
import rw from 'random-words';
|
|
3
3
|
import seedrandom from 'seedrandom/lib/alea.js';
|
|
4
4
|
|
|
5
|
-
var version = "8.2.
|
|
5
|
+
var version = "8.2.2";
|
|
6
6
|
|
|
7
7
|
class ExtensionManager {
|
|
8
8
|
constructor(dependencies, extensionsConfiguration) {
|
|
@@ -967,10 +967,35 @@ class MediaAPI {
|
|
|
967
967
|
return this.microphone_recorder;
|
|
968
968
|
}
|
|
969
969
|
initializeCameraRecorder(stream, opts) {
|
|
970
|
+
let mimeType = this.getCompatibleMimeType() || "video/webm";
|
|
971
|
+
const recorderOptions = {
|
|
972
|
+
...opts,
|
|
973
|
+
mimeType
|
|
974
|
+
};
|
|
970
975
|
this.camera_stream = stream;
|
|
971
|
-
const recorder = new MediaRecorder(stream,
|
|
976
|
+
const recorder = new MediaRecorder(stream, recorderOptions);
|
|
972
977
|
this.camera_recorder = recorder;
|
|
973
978
|
}
|
|
979
|
+
// mimetype checking code adapted from https://github.com/lookit/lookit-jspsych/blob/develop/packages/record/src/videoConfig.ts#L673-L699
|
|
980
|
+
/** returns a compatible mimetype string, or null if none from the array are supported. */
|
|
981
|
+
getCompatibleMimeType() {
|
|
982
|
+
const types = [
|
|
983
|
+
// chrome firefox edge
|
|
984
|
+
"video/webm;codecs=vp9,opus",
|
|
985
|
+
"video/webm;codecs=vp8,opus",
|
|
986
|
+
// general
|
|
987
|
+
"video/mp4;codecs=avc1.42E01E,mp4a.40.2",
|
|
988
|
+
// safari
|
|
989
|
+
"video/mp4;codecs=h264,aac",
|
|
990
|
+
"video/mp4;codecs=hevc,aac"
|
|
991
|
+
];
|
|
992
|
+
for (const mimeType of types) {
|
|
993
|
+
if (MediaRecorder.isTypeSupported(mimeType)) {
|
|
994
|
+
return mimeType;
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
return null;
|
|
998
|
+
}
|
|
974
999
|
getCameraStream() {
|
|
975
1000
|
return this.camera_stream;
|
|
976
1001
|
}
|