Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface Media

This plugin provides the ability to record and play back audio files on a device. NOTE: The current implementation does not adhere to a W3C specification for media capture, and is provided for convenience only. A future implementation will adhere to the latest W3C specification and may deprecate the current APIs.

Hierarchy

  • Media

Index

Properties

duration

duration: number

The duration of the media, in seconds.

position

position: number

The position within the audio playback, in seconds. Not automatically updated during play; call getCurrentPosition to update.

Methods

getCurrentPosition

  • getCurrentPosition(mediaSuccess: function, mediaError?: function): void
  • Returns the current position within an audio file. Also updates the Media object's position parameter.

    Parameters

    • mediaSuccess: function

      The callback that is passed the current position in seconds.

        • (position: number): void
        • Parameters

          • position: number

          Returns void

    • Optional mediaError: function

      The callback to execute if an error occurs.

        • (error: MediaError): void
        • Parameters

          • error: MediaError

          Returns void

    Returns void

getDuration

  • getDuration(): number
  • Returns the duration of an audio file in seconds. If the duration is unknown, it returns a value of -1.

    Returns number

pause

  • pause(): void
  • Pauses playing an audio file.

    Returns void

play

  • Starts or resumes playing an audio file.

    Parameters

    Returns void

release

  • release(): void
  • Releases the underlying operating system's audio resources. This is particularly important for Android, since there are a finite amount of OpenCore instances for media playback. Applications should call the release function for any Media resource that is no longer needed.

    Returns void

seekTo

  • seekTo(position: number): void
  • Sets the current position within an audio file.

    Parameters

    • position: number

      Position in milliseconds.

    Returns void

setVolume

  • setVolume(volume: number): void
  • Set the volume for an audio file.

    Parameters

    • volume: number

      The volume to set for playback. The value must be within the range of 0.0 to 1.0.

    Returns void

startRecord

  • startRecord(): void
  • Starts recording an audio file.

    Returns void

stop

  • stop(): void
  • Stops playing an audio file.

    Returns void

stopRecord

  • stopRecord(): void
  • Stops recording an audio file.

    Returns void