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.
@@ -51,7 +51,7 @@ var jsPsychModule = (function (exports) {
51
51
 
52
52
  var autoBind$1 = /*@__PURE__*/getDefaultExportFromCjs(autoBind);
53
53
 
54
- var version = "8.2.1";
54
+ var version = "8.2.2";
55
55
 
56
56
  class ExtensionManager {
57
57
  constructor(dependencies, extensionsConfiguration) {
@@ -1016,10 +1016,35 @@ var jsPsychModule = (function (exports) {
1016
1016
  return this.microphone_recorder;
1017
1017
  }
1018
1018
  initializeCameraRecorder(stream, opts) {
1019
+ let mimeType = this.getCompatibleMimeType() || "video/webm";
1020
+ const recorderOptions = {
1021
+ ...opts,
1022
+ mimeType
1023
+ };
1019
1024
  this.camera_stream = stream;
1020
- const recorder = new MediaRecorder(stream, opts);
1025
+ const recorder = new MediaRecorder(stream, recorderOptions);
1021
1026
  this.camera_recorder = recorder;
1022
1027
  }
1028
+ // mimetype checking code adapted from https://github.com/lookit/lookit-jspsych/blob/develop/packages/record/src/videoConfig.ts#L673-L699
1029
+ /** returns a compatible mimetype string, or null if none from the array are supported. */
1030
+ getCompatibleMimeType() {
1031
+ const types = [
1032
+ // chrome firefox edge
1033
+ "video/webm;codecs=vp9,opus",
1034
+ "video/webm;codecs=vp8,opus",
1035
+ // general
1036
+ "video/mp4;codecs=avc1.42E01E,mp4a.40.2",
1037
+ // safari
1038
+ "video/mp4;codecs=h264,aac",
1039
+ "video/mp4;codecs=hevc,aac"
1040
+ ];
1041
+ for (const mimeType of types) {
1042
+ if (MediaRecorder.isTypeSupported(mimeType)) {
1043
+ return mimeType;
1044
+ }
1045
+ }
1046
+ return null;
1047
+ }
1023
1048
  getCameraStream() {
1024
1049
  return this.camera_stream;
1025
1050
  }
@@ -4051,4 +4076,4 @@ var jsPsychModule = (function (exports) {
4051
4076
 
4052
4077
  })({});
4053
4078
  var initJsPsych = jsPsychModule.initJsPsych;
4054
- //# sourceMappingURL=https://unpkg.com/jspsych@8.2.1/dist/index.browser.js.map
4079
+ //# sourceMappingURL=https://unpkg.com/jspsych@8.2.2/dist/index.browser.js.map