Media Capture
The Media Capture plugin provides access to the device's audio, image, and video capture capabilities.
#
InstallationIf you have not already setup Ionic Enterprise in your app, follow the one-time setup steps.
Next, install the plugin:
- Capacitor
- Cordova
#
Index#
Classes#
Interfaces- CaptureAudioOptions
- CaptureError
- CaptureImageOptions
- CaptureVideoOptions
- ConfigurationData
- MediaFile
- MediaFileData
#
Classes#
MediaCaptureusage:
interfaces: MediaFile MediaFileData CaptureError CaptureAudioOptions CaptureImageOptions CaptureVideoOptions ConfigurationData
#
supportedAudioModes● supportedAudioModes: ConfigurationData[]
The audio recording formats supported by the device.
returns:
#
supportedImageModes● supportedImageModes: ConfigurationData[]
The recording image sizes and formats supported by the device.
returns:
#
supportedVideoModes● supportedVideoModes: ConfigurationData[]
The recording video resolutions and formats supported by the device.
returns:
#
captureAudio▸ captureAudio(options?: CaptureAudioOptions): Promise
<MediaFile[] | CaptureError>
Start the audio recorder application and return information about captured audio clip files.
Parameters:
Name | Type | Description |
---|---|---|
Optional options | CaptureAudioOptions | - |
Returns: Promise
<MediaFile[] | CaptureError>
#
captureImage▸ captureImage(options?: CaptureImageOptions): Promise
<MediaFile[] | CaptureError>
Start the camera application and return information about captured image files.
Parameters:
Name | Type | Description |
---|---|---|
Optional options | CaptureImageOptions | - |
Returns: Promise
<MediaFile[] | CaptureError>
#
captureVideo▸ captureVideo(options?: CaptureVideoOptions): Promise
<MediaFile[] | CaptureError>
Start the video recorder application and return information about captured video clip files.
Parameters:
Name | Type | Description |
---|---|---|
Optional options | CaptureVideoOptions | - |
Returns: Promise
<MediaFile[] | CaptureError>
#
onPendingCaptureError▸ onPendingCaptureError(): Observable
<CaptureError>
is fired if the capture call is unsuccessful
Returns: Observable
<CaptureError>
#
onPendingCaptureResult▸ onPendingCaptureResult(): Observable
<MediaFile[]>
is fired if the capture call is successful
Returns: Observable
<MediaFile[]>
#
Interfaces#
CaptureAudioOptionsCaptureAudioOptions:
<Optional>
duration#
● duration: number
Maximum duration of an audio sound clip, in seconds. This does not work on Android devices.
<Optional>
limit#
● limit: number
Maximum number of audio clips. Defaults to 1. On iOS you can only record one file.
#
CaptureErrorCaptureError:
#
code● code: string
#
CaptureImageOptionsCaptureImageOptions:
<Optional>
limit#
● limit: number
Maximum number of images to capture. This limit is not supported on iOS, only one image will be taken per invocation.
#
CaptureVideoOptionsCaptureVideoOptions:
<Optional>
duration#
● duration: number
Maximum duration per video clip. This will be ignored on BlackBerry.
<Optional>
limit#
● limit: number
Maximum number of video clips to record. This value is ignored on iOS, only one video clip can be taken per invocation.
<Optional>
quality#
● quality: number
Quality of the video. This parameter can only be used with Android.
#
ConfigurationDataConfigurationData:
#
height● height: number
The height of the image or video in pixels. The value is zero for sound clips.
#
type● type: string
The ASCII-encoded lowercase string representing the media type.
#
width● width: number
The width of the image or video in pixels. The value is zero for sound clips.
#
MediaFileMediaFile:
#
fullPath● fullPath: string
The full path of the file, including the name.
#
lastModifiedDate● lastModifiedDate: Date
The date and time when the file was last modified.
#
name● name: string
The name of the file, without path information.
#
size● size: number
The size of the file, in bytes.
#
type● type: string
The file's mime type
#
getFormatData▸ getFormatData(successCallback: function
, errorCallback?: function
): void
Retrieves the format information of the media file.
Parameters:
Name | Type | Description |
---|---|---|
successCallback | function | - |
Optional errorCallback | function |
Returns: void
#
MediaFileDataMediaFileData:
#
bitrate● bitrate: number
The average bitrate of the content. The value is zero for images.
#
codecs● codecs: string
The actual format of the audio and video content.
#
duration● duration: number
The length of the video or sound clip in seconds. The value is zero for images.
#
height● height: number
The height of the image or video in pixels. The value is zero for audio clips.
#
width● width: number
The width of the image or video in pixels. The value is zero for audio clips.