Skip to content

Commit

Permalink
feat(video-capture-plus): add Video Capture Plus plugin (#1538)
Browse files Browse the repository at this point in the history
* feat(plugin): Video Capture Plus

fix #709

* Updated interfaces
  • Loading branch information
danielsogl authored and ihadeed committed May 12, 2017
1 parent efae1be commit 385da01
Showing 1 changed file with 152 additions and 0 deletions.
152 changes: 152 additions & 0 deletions src/@ionic-native/plugins/video-capture-plus/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
import { Injectable } from '@angular/core';
import { Plugin, Cordova, IonicNativePlugin } from '@ionic-native/core';

export interface MediaFile {
/**
* The name of the file, without path information.
*/
name: string;
/**
* The full path of the file, including the name.
*/
fullPath: string;
/**
* The file's mime type
*/
type: string;

/**
* The date and time when the file was last modified.
*/
lastModifiedDate: Date;

/**
* The size of the file, in bytes.
*/
size: number;

/**
* Retrieves the format information of the media file.
* @param {Function} successCallback
* @param {Function} errorCallback
*/
getFormatData(successCallback: (data: MediaFileData) => any, errorCallback?: (err: any) => any);
}

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

export interface VideoCapturePlusOptions {

/**
* The number of videos to record, default 1 (on iOS always 1)
*/
limit?: number;

/**
* Max duration in seconds, default 0, which is 'forever'
*/
duration?: number;

/**
* Set to true to override the default low quality setting
*/
highquality?: boolean;

/**
* Set to true to override the default backfacing camera setting.
* You'll want to sniff the useragent/device and pass the best overlay based on that.. assuming iphone here
*/
frontcamera?: boolean;

/**
* put the png overlay in your assets folder
*/
portraitOverlay?: string;

/**
* not passing an overlay means no image is shown for the landscape orientation
*/
landscapeOverlay?: string;

/**
* iOS only
*/
overlayText?: string;

}

/**
* @beta
* @name Video Capture Plus
* @description
* This plugin offers some useful extras on top of the default Media Capture Plugin capabilities:
* - HD recording.
* - Starting with the front camera.
* - A custom overlay (currently iOS only).
*
* @usage
* ```typescript
* import { VideoCapturePlus, VideoCapturePlusOptions, MediaFile } from '@ionic-native/video-capture-plus';
*
*
* constructor(private videoCapturePlus: VideoCapturePlus) { }
*
* ...
*
* const options: VideoCapturePlusOptions = {
* limit: 1,
* highquality: true,
* portraitOverlay: 'assets/img/camera/overlay/portrait.png',
* landscapeOverlay: 'assets/img/camera/overlay/landscape.png'
* }
*
* this.videoCapturePlus.captureVideo(options).then(mediafile: MediaFile[] => console.log(mediafile), error => console.log('Something went wrong'));
*
* ```
* @interfaces
* MediaFile
* MediaFileData
* VideoCapturePlusOptions
*/
@Plugin({
pluginName: 'VideoCapturePlus',
plugin: 'https://github.com/EddyVerbruggen/VideoCapturePlus-PhoneGap-Plugin.git',
pluginRef: 'window.plugins.videocaptureplus',
repo: 'https://github.com/EddyVerbruggen/VideoCapturePlus-PhoneGap-Plugin',
platforms: ['Android', 'iOS']
})
@Injectable()
export class VideoCapturePlus extends IonicNativePlugin {

/**
* Starts recordings
* @param [options] {VideoCapturePlusOptions} Configure options
* @return {Promise<MediaFile[]>}
*/
@Cordova({
callbackOrder: 'reverse'
})
captureVideo(options?: VideoCapturePlusOptions): Promise<MediaFile[]> { return; }

}

0 comments on commit 385da01

Please sign in to comment.