MediaRecorder
element
description
Creates an audio and/or video recorder.
syntax
newMediaRecorder(ELEMENT_NAME: string, ["audio"], ["video"])
-
ELEMENT_NAME
: The name of the newly-created element. -
["audio"]
(optional): Records an audio stream. -
["video"]
(optional): Records a video stream.
note(s)
since
PennController 1.8example(s)
+ If the `"audio"` or `"video"` parameter is not passed, collects an audio-video sample. + The filename of the media file in the uploaded zip archives will be based on the MediaRecorder element's name
@newMediaRecorder("recorder", "audio")
@ .log()
@ .once()
@ .record()
@ .print()
@ .wait()
+ Creates an audio recorder, starts recording, prints an interface and wait until the participant stops the recorder Action commands
mediarecorder.log
syntax
.log()
description
Will add a line whenever a recording starts and whenever it stops.
example
click to expand
@newMediaRecorder("recorder")
$ .log()
@ .print()
@ .wait()
- Adds a media player and a recording button to the page and waits for a sample to be recorded. The filename will contain the timestamps of when the recording button was clicked: one line for the first click (starts recording) and one for the second click (stops recording).
mediarecorder.once
syntax
.once()
description
Disables the button to record after the first recording. You can still play back the recording, or programmatically start a new recording using the command record
.
example
click to expand
@InitiateRecorder("https://myserver/upload.php");
@
@newTrial(
@ newMediaRecorder("recorder")
$ .once()
@ .print()
@ .wait()
@ .play()
@ .wait("playback")
@);
- Adds a media player and a recording button to the page, and when the recording stops, the button becomes disabled and the video automatically plays back.
mediarecorder.play
syntax
.play()
description
Starts playing the last recording (if any).
example
click to expand
@InitiateRecorder("https://myserver/upload.php");
@
@newTrial(
@ newMediaRecorder("recorder")
@ .record()
@ ,
@ newTimer("recording", 2000)
@ .start()
@ .wait()
@ ,
@ getMediaRecorder("recorder")
@ .stop()
@ .print()
@ .disable()
$ .play()
@ .wait("playback")
@);
- Will record for 2s and then play back the recording.
mediarecorder.record
syntax
.record()
description
Starts recording.
example
click to expand
@InitiateRecorder("https://myserver/upload.php");
@
@newTrial(
@ newMediaRecorder("recorder","audio")
$ .record()
@ ,
@ newTimer("recording", 2000)
@ .start()
@ .wait()
@ ,
@ getMediaRecorder("recorder")
@ .stop()
@ .play()
@ .wait("playback")
@);
- Will record audio for 2s and then play it back.
mediarecorder.stop
syntax
.stop()
description
Stops recording / playing the latest sample.
example
click to expand
@InitiateRecorder("https://myserver/upload.php");
@
@newTrial(
@ newMediaRecorder("recorder")
@ .record()
@ ,
@ newTimer("recording", 3000)
@ .start()
@ .wait()
@ ,
@ getMediaRecorder("recorder")
@ .stop()
$ .disable()
@ .print()
@ .play()
@ ,
@ newTimer("preview", 1000)
@ .start()
@ .wait()
@ ,
@ getMediaRecorder("recorder")
$ .stop()
@);
- Will start recording a video and stop recording after 2s, then play back the first second of the recording and stop the playback.
mediarecorder.wait
syntax
.wait()
description
Waits for the current (or next) recording to be over.
example
click to expand
@InitiateRecorder("https://myserver/upload.php");
@
@newTrial(
@ newMediaRecorder("recorder")
@ .once()
@ .print()
$ .wait()
@ .play()
$ .wait("playback")
@)
- Adds a media player and a recording button to the page, and automatically plays back the video once it is recorded.
Test commands
mediarecorder.test.hasPlayed
syntax
.test.hasPlayed()
description
Tests whether the recording was ever played back.
example
click to expand
@newMediaRecorder("recorder")
@ .log()
@ .print()
,
@newButton("next", "Press to go to the next page")
@ .print()
@ .wait(getMediaRecorder("recorder").test.hasPlayed())
- Initiates new media recorder, and allows going to the next page by the button press only after the recording has played.
mediarecorder.test.playing
syntax
.test.playing()
description
Tests whether the recording is currently being played back.
example
click to expand
@newMediaRecorder("recorder")
@ .log()
@ .print()
,
@newButton("next", "Press to go to the next page")
@ .print()
@ .wait(getMediaRecorder("recorder").test.playing())
- Initiates new media recorder, and allows going to the next page by the button press only if the current recording is playing.
mediarecorder.test.recorded
syntax
.test.recorded()
description
Tests whether a recording was completed.
example
click to expand
@newMediaRecorder("recorder")
@ .log()
@ .print()
,
@newButton("next", "Press to go to the next page")
@ .print()
@ .wait(getMediaRecorder("recorder").test.recorded())
- Initiates new media recorder, and allows going to the next page by the button press only if recording was completed.