The new PCIbex Farm is here! Be sure to check out all of its new features and changes.

Link Search Menu Expand Document

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)

  • If the "audio" or "video" parameter is not passed, collects an audio-video sample.

since

PennController 1.8

example(s)


@newMediaRecorder("recorder", "audio")
@  .log()
@  .once()
@  .record()
@  .wait()
  • Initiates audio 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).
↑ back to top

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.
↑ back to top

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.
↑ back to top

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.
↑ back to top

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.
↑ back to top

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.
↑ back to top


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.
↑ back to top

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.
↑ back to top

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.
↑ back to top