module:tiny_recordrtc/base_recorder

module:tiny_recordrtc/base_recorder

The RecordRTC base class for audio, video, and any other future types

Constructor

new (require("tiny_recordrtc/base_recorder"))(editor, modal)

Source:

Constructor for the RecordRTC class

Parameters:
Name Type Description
editor TinyMCE

The Editor to which the content will be inserted

modal Modal

The Moodle Modal that contains the interface used for recording

Methods

(static) checkSecure() → {boolean}

Source:
See:

Check whether the hostname is either hosted over SSL, or from a valid localhost hostname.

The UserMedia API can only be used in secure contexts as noted.

Returns:

Whether the plugin can be loaded.

Type
boolean

(static) getModalClass() → {Modal}

Source:

Fetch the Class of the Modal to be displayed.

Returns:
Type
Modal

(static) hasUserMedia() → {boolean}

Source:

Check whether the browser supports WebRTC.

Returns:
Type
boolean

(static) isBrowserCompatible() → {boolean}

Source:

Check whether the browser is compatible with capturing media.

Returns:
Type
boolean

(async) captureUserMedia()

Source:

Start capturing the User Media and handle success or failure of the capture.

checkAndWarnAboutBrowserCompatibility() → {boolean}

Source:

Check whether the browser is compatible with capturing media, and display a warning if not.

Returns:
Type
boolean

cleanupStream()

Source:

Clean up the stream.

This involves stopping any track which is still active.

clearButtonTimer()

Source:

Clear the timer for the stop recording button.

close()

Source:

Close the modal and stop recording.

configurePlayer() → {HTMLElement}

Source:

Get the Player element for this type.

Returns:

The player element, typically an audio or video tag.

Type
HTMLElement

getButtonContainer(purpose) → {HTMLElement}

Source:

Helper to get the container that a button is in.

Parameters:
Name Type Description
purpose string

The button purpose

Returns:
Type
HTMLElement

getEmbedTemplateContext(templateContext) → {Object}

Source:

Add or modify the template parameters for the specified type.

Parameters:
Name Type Description
templateContext Object

The Tempalte context to use

Returns:

The finalised template context

Type
Object

getEmbedTemplateName() → {string}

Source:

Get the name of the template used when embedding the URL in the editor content.

Returns:
Type
string

getFileName(prefix) → {string}

Source:

Get a filename for the generated file.

Typically this function will take a prefix and add a type-specific suffix such as the extension to it.

Parameters:
Name Type Description
prefix string

The prefix for the filename generated by the recorder.

Returns:
Type
string

getMaxUploadSize() → {number}

Source:

Get the maximum file size that can be uploaded.

Returns:

The max byte size

Type
number

getMediaConstraints() → {Object}

Source:
See:

Get a list of constraints as required by the getUserMedia() function.

Returns:
Type
Object

getParsedRecordingOptions() → {object}

Source:

Get the options for the MediaRecorder.

Returns:

The options for the MediaRecorder instance.

Type
object

getRecordingOptions() → {Object}

Source:
See:

Get any recording options passed into the MediaRecorder. Please note that the mimeType will be fetched from getSupportedTypes().

Returns:
Type
Object

getSupportedTypes() → {Array.<string>}

Source:
See:

Get the list of supported mimetypes for this recorder.

Returns:

The list of supported mimetypes.

Type
Array.<string>

getTimeLimit() → {number}

Source:

Get the time limit for this recording type.

Returns:

The time limit in seconds.

Type
number

getTimeRemaining() → {Object}

Source:

Get the time remaining for the recording.

Returns:

The minutes and seconds remaining.

Type
Object

handleCaptureFailure(error)

Source:

Handle failure to capture the User Media.

Parameters:
Name Type Description
error Error

handleCaptureSuccess(stream)

Source:

Handle successful capture of the User Media.

Parameters:
Name Type Description
stream MediaStream

The stream as captured by the User Media.

handleDataAvailable(event)

Source:

Handle the mediaRecorder dataavailable event.

Parameters:
Name Type Description
event Event

handleModalClick(event)

Source:

Handle a click within the Modal.

Parameters:
Name Type Description
event MouseEvent

The click event

handleRecordingStartStopRequested()

Source:

Handle the click event for the recording start/stop button.

handleStarted()

Source:

Handle the mediaRecorder start event.

This event is called when the recording starts.

handleStopped()

Source:

Handle the mediaRecorder stop event.

hasData() → {boolean}

Source:

Whether any data has been recorded.

Returns:
Type
boolean

(async) insertMedia(source)

Source:

Insert the HTML to embed the recording into the editor content.

Parameters:
Name Type Description
source string

The URL to view the media.

isReady() → {boolean}

Source:

Check whether the browser is compatible.

Returns:
Type
boolean

isRecording() → {boolean}

Source:

Check whether the recording is in progress.

Returns:
Type
boolean

(async) onMediaStopped()

Source:

Handle the media stream after it has finished.

(async) outsideClickHandler(event)

Source:

Prevent the Modal from closing when recording is on process.

Parameters:
Name Type Description
event MouseEvent

The click event

playOnCapture() → {boolean}

Source:

Whether to start playing the recording as it is captured.

Returns:

Whether to start playing the recording as it is captured.

Type
boolean

prefetchContent()

Source:

Prefetch some of the content that will be used in the UI.

Note: not all of the strings used are pre-fetched. Some of the strings will be fetched because their template is used.

(async) recordAgainConfirmation() → {Promise.<boolean>}

Source:

Confirm whether the user wants to reset the existing recoring.

Returns:

Whether the user confirmed the reset.

Type
Promise.<boolean>

requestRecordingStop()

Source:

Stop the recording. Please note that this should only stop the recording. Anything related to processing the recording should be handled by the mediaRecorder's stopped event handler which is processed after it has stopped.

setRecordButtonState(enabled)

Source:

Enable the record button.

Parameters:
Name Type Description
enabled boolean | null

Set the button state

(async) setRecordButtonTextFromString(string)

Source:

Set the text of the record button using a language string.

Parameters:
Name Type Description
string string

The string identifier

setRecordButtonVisibility(visible)

Source:

Configure button visibility for the record button.

Parameters:
Name Type Description
visible boolean

Set the visibility of the button.

(async) setStopRecordingButton()

Source:

Update the content of the stop recording button timer.

setUploadButtonState(enabled)

Source:

Enable the upload button.

Parameters:
Name Type Description
enabled boolean | null

Set the button state

(async) setUploadButtonTextProgress(progress)

Source:

Set the upload button text progress.

Parameters:
Name Type Description
progress number

The progress

setUploadButtonVisibility(visible)

Source:

Configure button visibility for the upload button.

Parameters:
Name Type Description
visible boolean

Set the visibility of the button.

setupPlayerSource()

Source:

Setup the player to use the stream as a source.

(async) startRecording()

Source:

Start the recording

updateRecordButtonTime()

Source:

Update the time on the stop recording button.

(async) uploadRecording()

Source:

Upload the recording and insert it into the editor content.