MediaCapture

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

Usage
var options= { limit: 5 };

MediaCapture.captureImage(options)
    .then((files) => {   
        for(let i = 0 ; i < files.length ; i++){
            console.log(files[i].fullPath);
            console.log(files[i].size);
            console.log(files[i].type);

            files[i].getFormatData((data)=>{
                console.log(data.width);
                console.log(data.height);
            });
        }
    }).catch((error) => {
        console.error(error);
    });
var options = { limit: 5 };
window.MediaCapture.captureImage(options)
    .then((files) => {
        for (let i = 0; i < files.length; i++) {
            console.log(files[i].fullPath);
            console.log(files[i].size);
            console.log(files[i].type);

            files[i].getFormatData((data) => {
                console.log(data.width);
                console.log(data.height);
            });
        }
    })
    .catch((error) => {
        console.error(error);
    });
var options = { limit: 5 };
window.MediaCapture.captureImage(options)
    .then((files) => {
        for (let i = 0; i < files.length; i++) {
            console.log(files[i].fullPath);
            console.log(files[i].size);
            console.log(files[i].type);

            files[i].getFormatData((data) => {
                console.log(data.width);
                console.log(data.height);
            });
        }
    })
    .catch((error) => {
        console.error(error);
    });
var options = { limit: 5 };
(<any>window).MediaCapture.captureImage(options)
    .then((files) => {
        for (let i = 0; i < files.length; i++) {
            console.log(files[i].fullPath);
            console.log(files[i].size);
            console.log(files[i].type);

            files[i].getFormatData((data) => {
            console.log(data.width);
            console.log(data.height);
            });
        }
    })
    .catch((error) => {
        console.error(error);
    });
var options = { limit: 5 };
window.MediaCapture.captureImage(options)
    .then((files) => {
        for (let i = 0; i < files.length; i++) {
            console.log(files[i].fullPath);
            console.log(files[i].size);
            console.log(files[i].type);

            files[i].getFormatData((data) => {
                console.log(data.width);
                console.log(data.height);
            });
        }
    })
    .catch((error) => {
        console.error(error);
    });

Classes


MediaCapture

captureAudio

captureAudio(options?: CaptureAudioOptions): Promise<MediaFile[] | CaptureError>

Start the audio recorder application and return information about captured audio clip files.


PARAMETERS
options: CaptureAudioOptions

RETURN
returns: Promise <MediaFile[] | CaptureError>
PERMISSIONS

This method requires STORAGE Permission set on Fawi Office - publish settings.

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

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


PARAMETERS
options: CaptureImageOptions

RETURN
returns: Promise <MediaFile[] | CaptureError>
PERMISSIONS

This method requires CAMERA and STORAGE Permissions set on Fawi Office - publish settings.

captureVideo
captureVideo(options:? CaptureVideoOptions): Promise<MediaFile[] | CaptureError>

Start the video recorder application and return information about captured video clip files.


PARAMETERS
options: CaptureVideoOptions

RETURN
returns: Promise <MediaFile[] | CaptureError>
PERMISSIONS

This method requires CAMERA and STORAGE Permissions set on Fawi Office - publish settings.

Interfaces

CaptureAudioOptions

interface CaptureAudioOptions {
    // Maximum number of audio clips. Defaults to 1
    limit: int,
    // Maximum duration of a single sound clip in seconds.
    duration: int
}

CaptureError

interface CaptureError {
    code: int
}

CaptureImageOptions

interface CaptureImageOptions {
    // Maximum number of images to capture
    limit: int
}

CaptureVideoOptions

interface CaptureVideoOptions {
    // Maximum duration per video clip
    duration: int,
    // Maximum number of video clips to record
    limit: int,
    // Quality of the video
    quality: int
}

MediaFile

interface MediaFile {
    // The full path of the file, including the name
    fullPath: string,
    // The date and time when the file was last modified
    lastModifiedDate: date,
    // The name of the file, without path information
    name: string,
    // The size of the file, in bytes
    size: int,
    // The file's mime type
    type: string,
    // Retrieves the format information of the media file.
    getFormatData(successCallback: function(data : MediaFileData), errorCallback?: function): void
}

MediaFileData

interface MediaFileData {
    // The average bitrate of the content. The value is zero for images
    bitrate: int,
    // The actual format of the audio and video content
    codecs: string,
    // The length of the video or sound clip in seconds. The value is zero for images
    duration: int,
    // The height of the image or video in pixels. The value is zero for audio clips
    height: int,
    // The width of the image or video in pixels. The value is zero for audio clips
    width: int
}