Video-record Class
These docs have moved here.Reference for DEVELOPERS of new frames only!
A mixin that can be used to add basic support for video recording across frames
By default, the recorder will be installed when this frame loads, but recording
will not start automatically. To override either of these settings, set
the properties doUseCamera
and/or startRecordingAutomatically
in the consuming
frame.
You will also need to set recorderElement
if the recorder is to be housed other than
in an element identified by the ID recorder
.
The properties recorder
, videoList
, stoppedRecording
, recorderReady
, and
videoId
become available to the consuming frame. The recorder object has fields
that give information about its state: hasWebCam
, 'hasCamAccess,
recording,
connected, and
micChecked- for details, see services/video-recorder.js. These can be accessed from the consuming frame as e.g.
this.get('recorder').get('hasWebCam'). If starting recording automatically, the function
onRecordingStartedwill be called once recording begins. If you want to do other things at this point, like proceeding to a test trial, you can add this hook in your frame. See 'methods' for the functions you can use on a frame that extends VideoRecord. Events recorded in a frame that extends VideoRecord will automatically have additional fields videoId (video filename), pipeId (temporary filename initially assigned by the recording service), and streamTime (when in the video they happened, in s). Setting up the camera is handled in didInsertElement, and making sure recording is stopped is handled in willDestroyElement (Ember hooks that fire during the component lifecycle). It is very important (in general, but especially when using this mixin) that you call
this._super(...arguments);` in any functions where your frame overrides
hooks like this, so that the mixin's functions get called too!
Item Index
Methods
Properties
- audioOnly
- autosave
- doUseCamera
- maxRecordingLength
- maxUploadSeconds
- recorder
- recorderElement
- recorderReady
- showWaitForRecordingMessage
- showWaitForUploadMessage
- startRecordingAutomatically
- stoppedRecording
- videoId
- videoList
- waitForRecordingMessage
- waitForRecordingMessageColor
- waitForUploadMessage
- waitForUploadMessageColor
- waitForWebcamImage
- waitForWebcamVideo
Methods
destroyRecorder
()
Destroy recorder and stop accessing webcam
hideRecorder
()
Hide the recorder from display. Useful if you would like to keep recording without extra UI elements to distract the user.
makeTimeEvent
-
eventName
-
extra
Extend any base time event capture with information about the recorded video
Returns:
Event data object
onRecordingStarted
()
Function called when frame recording is started automatically. Override to do frame-specific actions at this point (e.g., beginning a test trial).
setupRecorder
-
element
Set up a video recorder instance
Parameters:
-
element
NodeA DOM node representing where to mount the recorder
Returns:
A promise representing the result of installing the recorder
showRecorder
()
Show the recorder to the user. Useful if you want to temporarily show a hidden recorder- eg to let the user fix a problem with video capture settings
startRecorder
()
Start recording
Returns:
Promise Resolves when recording has started
stopRecorder
()
Stop the recording
Returns:
Promise A promise that resolves when upload is complete
whenPossibleToRecordObserver
()
Observer that starts recording once recorder is ready.
Properties
audioOnly
Number
Whether to do audio-only (vs also video) recording. Can be overridden by consuming frame.
Default: 0
autosave
Number
private
Whether to autosave recordings. Can be overridden by consuming frame. TODO: eventually use this to set up non-recording option for previewing
Default: 1
doUseCamera
Boolean
Whether to use the camera in this frame. Consuming frame should set this property to override if needed.
Default: true
maxRecordingLength
Number
Maximum recording length in seconds. Can be overridden by consuming frame.
Default: 7200
maxUploadSeconds
Number
Maximum time allowed for video upload before proceeding, in seconds. Can be overridden by researcher, based on tradeoff between making families wait and losing data.
Default: 5
recorder
VideoRecorder
private
The recorder object, accessible to the consuming frame. Includes properties recorder.nWebcams, recorder.hasCamAccess, recorder.micChecked, recorder.connected.
recorderReady
Boolean
private
Whether recorder has been set up yet. Automatically set when doing setup. Accessible to consuming frame.
showWaitForRecordingMessage
Boolean
Whether to initially show a message saying to wait until recording starts, covering the entire frame. This prevents participants from seeing any stimuli before recording begins. Only used if recording is being started immediately.
Default: true
showWaitForUploadMessage
Boolean
Whether to stop media and hide stimuli with a message saying to wait for video upload when stopping recording. Do NOT set this to true if end of recording does not correspond to end of the frame (e.g. during consent or observation frames) since it will hide everything upon stopping the recording!
Default: true
startRecordingAutomatically
Boolean
Whether to start recording ASAP (only applies if doUseCamera). Consuming frame should set to override if needed.
Default: false
stoppedRecording
Boolean
private
Whether recording is stopped already, meaning it doesn't need to be re-stopped when destroying frame. This should be set to true by the consuming frame when video is stopped.
videoId
String
private
A video ID to use for the current recording. Format is
videoStream_<experimentId>_<frameId>_<sessionId>_timestampMS_RRR
where RRR are random numeric digits.
videoList
List
private
A list of all video IDs used in this mixin (a new one is created for each recording). Accessible to consuming frame.
waitForRecordingMessage
Boolean
[Only used if showWaitForRecordingMessage is true] Text to display while waiting for recording to begin.
Default: 'Please wait... <br><br> starting webcam recording'
waitForRecordingMessageColor
Boolean
[Only used if showWaitForRecordingMessage is true] Background color of screen while waiting for recording to begin. See https://developer.mozilla.org/en-US/docs/Web/CSS/color_value for acceptable syntax: can use either color names ('blue', 'red', 'green', etc.), or rgb hex values (e.g. '#800080' - include the '#'). The text on top of this will be either black or white depending on which will have higher contrast.
Default: 'white'
waitForUploadMessage
Boolean
[Only used if showWaitForUploadMessage is true] Text to display while waiting for recording to begin.
Default: 'Please wait... <br><br> uploading video'
waitForUploadMessageColor
String
[Only used if showWaitForUploadMessage is true] Background color of screen while waiting for recording to upload. See https://developer.mozilla.org/en-US/docs/Web/CSS/color_value for acceptable syntax: can use either color names ('blue', 'red', 'green', etc.), or rgb hex values (e.g. '#800080' - include the '#'). The text on top of this will be either black or white depending on which will have higher contrast.
Default: 'white'
waitForWebcamImage
String
[Only used if showWaitForUploadMessage and/or showWaitForRecordingMessage are true] Image to display along with
any wait-for-recording or wait-for-upload message. Either waitForWebcamImage or waitForWebcamVideo can be
specified. This can be either a full URL ('https://...') or just a filename, which will be assumed to be
inside baseDir/img/
if this frame otherwise supports use of baseDir
.
Default: ''
waitForWebcamVideo
String
[Only used if showWaitForUploadMessage and/or showWaitForRecordingMessage are true] Video to display along with
any wait-for-recording or wait-for-upload message (looping). Either waitForWebcamImage or waitForWebcamVideo can be
specified. This can be either an array of {'src': 'https://...', 'type': '...'}
objects (e.g. providing both
webm and mp4 versions at specified URLS) or a single string relative to baseDir/<EXT>/
if this frame otherwise
supports use of baseDir
.
Default: ''
Events
pauseVideo
When pausing study, immediately before request to pause webcam recording
recorderReady
When video recorder has been installed
stoppingCapture
Just before stopping webcam video capture
unpauseVideo
When unpausing study, immediately before request to resume webcam recording
videoStreamConnection
When recorder detects a change in video stream connection status
Event Payload:
-
status
Stringstatus of video stream connection, e.g. 'NetConnection.Connect.Success' if successful