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)

Description:
  • Constructor for the RecordRTC class

Source:
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

(async) captureUserMedia()

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

Source:

checkAndWarnAboutBrowserCompatibility() → {boolean}

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

Source:
Returns:
Type
boolean

cleanupStream()

Description:
  • Clean up the stream.

    This involves stopping any track which is still active.

Source:

clearButtonTimer()

Description:
  • Clear the timer for the stop recording button.

Source:

close()

Description:
  • Close the modal and stop recording.

Source:

configurePlayer() → {HTMLElement}

Description:
  • Get the Player element for this type.

Source:
Returns:

The player element, typically an audio or video tag.

Type
HTMLElement

getButtonContainer(purpose) → {HTMLElement}

Description:
  • Helper to get the container that a button is in.

Source:
Parameters:
Name Type Description
purpose string

The button purpose

Returns:
Type
HTMLElement

getEmbedTemplateContext(templateContext) → {Object}

Description:
  • Add or modify the template parameters for the specified type.

Source:
Parameters:
Name Type Description
templateContext Object

The Tempalte context to use

Returns:

The finalised template context

Type
Object

getEmbedTemplateName() → {string}

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

Source:
Returns:
Type
string

getFileName(prefix) → {string}

Description:
  • 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.

Source:
Parameters:
Name Type Description
prefix string

The prefix for the filename generated by the recorder.

Returns:
Type
string

getMaxUploadSize() → {number}

Description:
  • Get the maximum file size that can be uploaded.

Source:
Returns:

The max byte size

Type
number

getMediaConstraints() → {Object}

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

Source:
See:
Returns:
Type
Object

getParsedRecordingOptions() → {object}

Description:
  • Get the options for the MediaRecorder.

Source:
Returns:

The options for the MediaRecorder instance.

Type
object

getRecordingOptions() → {Object}

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

Source:
See:
Returns:
Type
Object

getSupportedTypes() → {Array.<string>}

Description:
  • Get the list of supported mimetypes for this recorder.

Source:
See:
Returns:

The list of supported mimetypes.

Type
Array.<string>

getTimeLimit() → {number}

Description:
  • Get the time limit for this recording type.

Source:
Returns:

The time limit in seconds.

Type
number

getTimeRemaining() → {Object}

Description:
  • Get the time remaining for the recording.

Source:
Returns:

The minutes and seconds remaining.

Type
Object

handleCaptureFailure(error)

Description:
  • Handle failure to capture the User Media.

Source:
Parameters:
Name Type Description
error Error

handleCaptureSuccess(stream)

Description:
  • Handle successful capture of the User Media.

Source:
Parameters:
Name Type Description
stream MediaStream

The stream as captured by the User Media.

handleDataAvailable(event)

Description:
  • Handle the mediaRecorder dataavailable event.

Source:
Parameters:
Name Type Description
event Event

handleModalClick(event)

Description:
  • Handle a click within the Modal.

Source:
Parameters:
Name Type Description
event MouseEvent

The click event

handlePaused()

Description:
  • Handle the mediaRecorder pause event.

    This event is called when the recording pauses.

Source:

handleRecordingPauseResumeRequested()

Description:
  • Handle the click event for the recording pause/resume button.

Source:

handleRecordingStartStopRequested()

Description:
  • Handle the click event for the recording start/stop button.

Source:

handleResume()

Description:
  • Handle the mediaRecorder resume event.

    This event is called when the recording resumes.

Source:

handleStarted()

Description:
  • Handle the mediaRecorder start event.

    This event is called when the recording starts.

Source:

handleStopped()

Description:
  • Handle the mediaRecorder stop event.

Source:

hasData() → {boolean}

Description:
  • Whether any data has been recorded.

Source:
Returns:
Type
boolean

(async) insertMedia(source)

Description:
  • Insert the HTML to embed the recording into the editor content.

Source:
Parameters:
Name Type Description
source string

The URL to view the media.

isPaused() → {boolean}

Description:
  • Check whether the recording is paused.

Source:
Returns:
Type
boolean

isReady() → {boolean}

Description:
  • Check whether the browser is compatible.

Source:
Returns:
Type
boolean

isRecording() → {boolean}

Description:
  • Check whether the recording is in progress.

Source:
Returns:
Type
boolean

(async) onMediaStopped()

Description:
  • Handle the media stream after it has finished.

Source:

(async) outsideClickHandler(event)

Description:
  • Prevent the Modal from closing when recording is on process.

Source:
Parameters:
Name Type Description
event MouseEvent

The click event

pauseButtonTimer()

Description:
  • Pause the timer for the stop recording button.

Source:

playOnCapture() → {boolean}

Description:
  • Whether to start playing the recording as it is captured.

Source:
Returns:

Whether to start playing the recording as it is captured.

Type
boolean

prefetchContent()

Description:
  • 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.

Source:

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

Description:
  • Confirm whether the user wants to reset the existing recoring.

Source:
Returns:

Whether the user confirmed the reset.

Type
Promise.<boolean>

requestRecordingStop()

Description:
  • 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.

Source:

(async) setPauseButtonTextFromString(string)

Description:
  • Set the text of the pause button using a language string.

Source:
Parameters:
Name Type Description
string string

The string identifier

setPauseButtonVisibility(visible)

Description:
  • Configure button visibility for the pause button.

Source:
Parameters:
Name Type Description
visible boolean

Set the visibility of the button.

setPlayerState(state)

Description:
  • Sets the state of the audio player, including visibility, muting, and controls.

Source:
Parameters:
Name Type Description
state boolean

A boolean indicating the audio player state.

setRecordButtonState(enabled)

Description:
  • Enable the record button.

Source:
Parameters:
Name Type Description
enabled boolean | null

Set the button state

(async) setRecordButtonTextFromString(string)

Description:
  • Set the text of the record button using a language string.

Source:
Parameters:
Name Type Description
string string

The string identifier

setRecordButtonVisibility(visible)

Description:
  • Configure button visibility for the record button.

Source:
Parameters:
Name Type Description
visible boolean

Set the visibility of the button.

(async) setStopRecordingButton()

Description:
  • Update the content of the stop recording button timer.

Source:

setUploadButtonState(enabled)

Description:
  • Enable the upload button.

Source:
Parameters:
Name Type Description
enabled boolean | null

Set the button state

(async) setUploadButtonTextProgress(progress)

Description:
  • Set the upload button text progress.

Source:
Parameters:
Name Type Description
progress number

The progress

setUploadButtonVisibility(visible)

Description:
  • Configure button visibility for the upload button.

Source:
Parameters:
Name Type Description
visible boolean

Set the visibility of the button.

setupPlayerSource()

Description:
  • Setup the player to use the stream as a source.

Source:

startButtonTimer()

Description:
  • Start the timer for the start recording button. If the recording was paused, the timer will resume from the pause time.

Source:

(async) startRecording()

Description:
  • Start the recording

Source:

updateRecordButtonTime()

Description:
  • Update the time on the stop recording button.

Source:

(async) uploadRecording()

Description:
  • Upload the recording and insert it into the editor content.

Source:

(static) checkSecure() → {boolean}

Description:
  • 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.

Source:
See:
Returns:

Whether the plugin can be loaded.

Type
boolean

(static) getModalClass() → {Modal}

Description:
  • Fetch the Class of the Modal to be displayed.

Source:
Returns:
Type
Modal

(static) hasUserMedia() → {boolean}

Description:
  • Check whether the browser supports WebRTC.

Source:
Returns:
Type
boolean

(static) isBrowserCompatible() → {boolean}

Description:
  • Check whether the browser is compatible with capturing media.

Source:
Returns:
Type
boolean