Give us feedback
media-plugin
Mobile icon

Media Plugin

Stable version 7.0.0 (Compatible with OutSystems 11)
Uploaded on 23 Jan by 
0.0
 (0 ratings)
media-plugin

Media Plugin

Documentation
7.0.0

Media Plugin

This plugin provides the ability to record and playback audio files on a device.


Changes to the original Cordova-Plugin-Media

  • Plugin.xml

    • Added this line for the android 

      • <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />


Version of the Cordova-Plugin-Media Used

7.0.0


Client Actions

  • AudioInfo

    • CheckStatus

    • GetCurrentAmplitude

    • GetCurrentPosition

    • GetDuration

  • AudioPlaybackControls

    • Pause

    • Play

    • Resume

    • Stop

  • AudioRecordControls

    • StartRecord

    • StopRecord

  • AudioSettings

    • SeekTo

    • SetRate

    • SetVolume

  • Other

    • CheckMediaPlugin

    • Release


Structures

  • CallResult

    • Code <Integer>

    • Message <Text>


Outputs - Codes and Messages

The error output will include a code and a message from Cordova, except for the special case of code -1. This custom code was introduced specifically for the GetDuration Action to manage its failure, as it does not return a MediaError Object from Cordova.

A code of -1 was assigned with the foresight of potential future releases introducing new codes. This measure serves to avoid any conflict with future codes and ensures that this custom code remains distinct.

  • Error (CallResult)

    • -1 = “Duration not available” (Only for getDuration)

    • (0…x) = An error message from Cordova describing the details of the error


The status output will feature a code from Cordova along with a message assigned by this component to clarify its significance.

  • Status (CallResult)

    • 0 = “None”

    • 1 = “Starting”

    • 2 = “Running”

    • 3 = “Paused”

    • 4 = “Stopped”


CheckStatus

Returns the status of the current audio file being played or recorded.

  • Outputs

    • Error (CallResult)

    • Status (CallResult)


GetCurrentAmplitude

Returns the current amplitude within an audio file.

  • Outputs

    • Error (CallResult)

    • IsSuccess <Boolean>

    • Amplitude <Decimal>


GetCurrentPosition

Returns the current position (in seconds) within an audio file.

  • Outputs

    • Error (CallResult)

    • IsSuccess <Boolean>

    • Positions <Decimal> 


GetDuration

Returns the duration of an audio file in seconds.

  • Inputs

    • Source <Text> (File name. Example: "audio.aac")

  • Outputs

    • Error (CallResult)

    • IsSuccess <Boolean>

    • Duration <Decimal>


Pause

Pause playback of an audio file.

  • Outputs

    • Error (CallResult)

    • Status (CallResult)

    • IsSuccess <Boolean>


Play

Starts playing an audio file.

  • Inputs

    • Source <Text> (File name. Example: "audio.aac")

  • Outputs

    • Error (CallResult)

    • IsSuccess <Boolean>

    • Duration <Decimal>


Resume

Resumes playing an audio file.

  • Outputs

    • Error (CallResult)

    • IsSuccess <Boolean>

    • Duration <Decimal>


Stop

Stop playing an audio file.

  • Outputs

    • Error (CallResult)

    • IsSuccess <Boolean>

    • Duration <Decimal>


Note: The release() will be called in this flow.


StartRecord

Start recording an audio file.

  • Inputs

    • Source <Text> (File name. Example: "audio.aac")

  • Outputs

    • Error (CallResult)

    • IsSuccess <Boolean>

    • Duration <Decimal>


StopRecord

Stop recording an audio file.


  • Outputs

    • Error (CallResult)

    • IsSuccess <Boolean>

    • Duration <Decimal>


Note: The release() will be called in this flow.


SeekTo

Moves the position within the audio file.

  • Inputs

    • Milliseconds <Decimal> 

  • Outputs

    • Error (CallResult)

    • IsSuccess <Boolean>


SetRate

Set the playback rate for the audio file.

  • Inputs

    • Rate <Decimal> (Example: 2.0)

  • Outputs

    • Error (CallResult)

    • IsSuccess <Boolean>


SetVolume

Set the volume for audio playback.

  • Inputs

    • Volume <Decimal> (The value must be within the range of 0.0 to 1.0).

  • Outputs

    • Error (CallResult)

    • IsSuccess <Boolean>


CheckMediaPlugin

Checks if Cordova Media Plugin is available or not.

  • Outputs

    • Error (CallResult)

    • IsSuccess <Boolean>


Note: In this action, it's also checked if cordova is available from CommonPlugin.


Release

Releases the underlying operating system's audio resources.

  • Outputs

    • Error (CallResult)

    • IsSuccess <Boolean>


Observations

  • Not tested on iOS

  • I omitted two additional options for the play() method in Cordova (numberOfLoops and playAudioWhenScreenIsLocked) specifically because I wanted to avoid incorporating elements that I couldn't verify through testing.
    The same applies to pauseRecord() and resumeRecord() methods.

  • You may need the File Plugin (supported by OutSystems) to view files recorded.

  • I'll make an effort to stay in sync with Cordova's media plugin changes to ensure this component remains current. If you'd rather not receive updates, feel free to tag your preferred version directly from my GitHub repository in the Extensibility Configuration module property.


Links

Cordova-plugin-media

GitHub - apache/cordova-plugin-media

GitHub - VITOR-EFL-DEV/cordova-plugin-media