diff --git a/.changeset/sixty-ears-tan.md b/.changeset/sixty-ears-tan.md new file mode 100644 index 0000000000..0404a468ef --- /dev/null +++ b/.changeset/sixty-ears-tan.md @@ -0,0 +1,5 @@ +--- +"jspsych": patch +--- + +add a default `mimeType` of `"video/webm" to `initializeCameraRecorder()` diff --git a/docs/reference/jspsych-pluginAPI.md b/docs/reference/jspsych-pluginAPI.md index b7fa6005eb..81b036ef3b 100644 --- a/docs/reference/jspsych-pluginAPI.md +++ b/docs/reference/jspsych-pluginAPI.md @@ -507,8 +507,7 @@ None. #### Description -Generates a `MediaRecorder` object from provided `MediaStream` and stores this for access via [`getCameraRecorder()`](#getcamerarecorder). - +Generates a `MediaRecorder` object from provided `MediaStream` and stores this for access via [`getCameraRecorder()`](#getcamerarecorder). By default, `mimeType` is set to `"video/webm"`. #### Example ```javascript diff --git a/examples/extension-record-video.html b/examples/extension-record-video.html index 29cf9ee570..5008fd0ebf 100644 --- a/examples/extension-record-video.html +++ b/examples/extension-record-video.html @@ -13,7 +13,10 @@ const jsPsych = initJsPsych({ extensions: [ {type: jsPsychExtensionRecordVideo} - ] + ], + on_finish: function() { + jsPsych.data.displayData(); + } }); const initCamera = { diff --git a/packages/jspsych/src/modules/plugin-api/MediaAPI.ts b/packages/jspsych/src/modules/plugin-api/MediaAPI.ts index 6dabb44760..de50e0af3d 100644 --- a/packages/jspsych/src/modules/plugin-api/MediaAPI.ts +++ b/packages/jspsych/src/modules/plugin-api/MediaAPI.ts @@ -284,6 +284,12 @@ export class MediaAPI { private camera_recorder: MediaRecorder = null; initializeCameraRecorder(stream: MediaStream, opts?: MediaRecorderOptions) { + if (!opts) { + opts = { mimeType: "video/webm" }; + } else if (!opts.mimeType) { + opts.mimeType = "video/webm"; + } + this.camera_stream = stream; const recorder = new MediaRecorder(stream, opts); this.camera_recorder = recorder;