The Media Capture API provides access to the device's audio, image, and video capture capabilities.
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);
});
captureAudio(options?: CaptureAudioOptions): Promise<MediaFile[] | CaptureError>
Start the audio recorder application and return information about captured audio clip files.
captureImage(options:? CaptureImageOptions): Promise<MediaFile[] | CaptureError>
Start the camera application and return information about captured image files.
captureVideo(options:? CaptureVideoOptions): Promise<MediaFile[] | CaptureError>
Start the video recorder application and return information about captured video clip files.
interface CaptureAudioOptions {
// Maximum number of audio clips. Defaults to 1
limit: int,
// Maximum duration of a single sound clip in seconds.
duration: int
}
interface CaptureError {
code: int
}
interface CaptureImageOptions {
// Maximum number of images to capture
limit: int
}
interface CaptureVideoOptions {
// Maximum duration per video clip
duration: int,
// Maximum number of video clips to record
limit: int,
// Quality of the video
quality: int
}
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
}
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
}