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.cjs CHANGED
@@ -4,7 +4,7 @@ var autoBind = require('auto-bind');
4
4
  var rw = require('random-words');
5
5
  var seedrandom = require('seedrandom/lib/alea.js');
6
6
 
7
- var version = "8.2.1";
7
+ var version = "8.2.2";
8
8
 
9
9
  class ExtensionManager {
10
10
  constructor(dependencies, extensionsConfiguration) {
@@ -969,10 +969,35 @@ class MediaAPI {
969
969
  return this.microphone_recorder;
970
970
  }
971
971
  initializeCameraRecorder(stream, opts) {
972
+ let mimeType = this.getCompatibleMimeType() || "video/webm";
973
+ const recorderOptions = {
974
+ ...opts,
975
+ mimeType
976
+ };
972
977
  this.camera_stream = stream;
973
- const recorder = new MediaRecorder(stream, opts);
978
+ const recorder = new MediaRecorder(stream, recorderOptions);
974
979
  this.camera_recorder = recorder;
975
980
  }
981
+ // mimetype checking code adapted from https://github.com/lookit/lookit-jspsych/blob/develop/packages/record/src/videoConfig.ts#L673-L699
982
+ /** returns a compatible mimetype string, or null if none from the array are supported. */
983
+ getCompatibleMimeType() {
984
+ const types = [
985
+ // chrome firefox edge
986
+ "video/webm;codecs=vp9,opus",
987
+ "video/webm;codecs=vp8,opus",
988
+ // general
989
+ "video/mp4;codecs=avc1.42E01E,mp4a.40.2",
990
+ // safari
991
+ "video/mp4;codecs=h264,aac",
992
+ "video/mp4;codecs=hevc,aac"
993
+ ];
994
+ for (const mimeType of types) {
995
+ if (MediaRecorder.isTypeSupported(mimeType)) {
996
+ return mimeType;
997
+ }
998
+ }
999
+ return null;
1000
+ }
976
1001
  getCameraStream() {
977
1002
  return this.camera_stream;
978
1003
  }