Skip to main content

Media Capture

The Media Capture plugin provides access to the device's audio, image, and video capture capabilities.

Installation#

If you have not already setup Ionic Enterprise in your app, follow the one-time setup steps.

Next, install the plugin:

npm install @ionic-enterprise/media-capturenpx cap sync

Index#

Classes#

Interfaces#


Classes#

MediaCapture#

usage:

import { MediaCapture, MediaFile, CaptureError, CaptureImageOptions } from '@ionic-enterprise/media-capture/ngx';
constructor(private mediaCapture: MediaCapture) { }
...
let options: CaptureImageOptions = { limit: 3 }this.mediaCapture.captureImage(options) .then(   (data: MediaFile[]) => console.log(data),   (err: CaptureError) => console.error(err) );

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:

NameTypeDescription
Optional optionsCaptureAudioOptions-

Returns: Promise<MediaFile[] | CaptureError>


captureImage#

captureImage(options?: CaptureImageOptions): Promise<MediaFile[] | CaptureError>

Start the camera application and return information about captured image files.

Parameters:

NameTypeDescription
Optional optionsCaptureImageOptions-

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:

NameTypeDescription
Optional optionsCaptureVideoOptions-

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#

CaptureAudioOptions#

CaptureAudioOptions:

<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.



CaptureError#

CaptureError:

code#

● code: string



CaptureImageOptions#

CaptureImageOptions:

<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.



CaptureVideoOptions#

CaptureVideoOptions:

<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.



ConfigurationData#

ConfigurationData:

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.



MediaFile#

MediaFile:

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:

NameTypeDescription
successCallbackfunction-
Optional errorCallbackfunction

Returns: void



MediaFileData#

MediaFileData:

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.