From 1f535826a296556252d5c0c8da5cb6aaa8fec656 Mon Sep 17 00:00:00 2001 From: jade <101148768+jadeddelta@users.noreply.github.com> Date: Fri, 31 Jan 2025 17:29:37 -0500 Subject: [PATCH] add default `mimeType` if none is specified --- .changeset/sixty-ears-tan.md | 5 +++++ docs/reference/jspsych-pluginAPI.md | 3 +-- examples/extension-record-video.html | 5 ++++- packages/jspsych/src/modules/plugin-api/MediaAPI.ts | 6 ++++++ 4 files changed, 16 insertions(+), 3 deletions(-) create mode 100644 .changeset/sixty-ears-tan.md diff --git a/.changeset/sixty-ears-tan.md b/.changeset/sixty-ears-tan.md new file mode 100644 index 00000000..0404a468 --- /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 b7fa6005..81b036ef 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 29cf9ee5..5008fd0e 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 6dabb447..de50e0af 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;