i created an app to take pictures via cordova i would like to integrate the ability to take multiple pictures without leaving the camera ES: click on the button, take 10 photos and then upload them as does whatsapp for example
CodePudding user response:
Use Media Capture Plugin it have Limit Options for Multiple Images:
Installation:
ionic cordova plugin add cordova-plugin-media-capture
npm install @ionic-native/media-capture
import { MediaCapture, MediaFile, CaptureError, CaptureImageOptions, CaptureVideoOptions } from '@ionic-native/media-capture/ngx';
constructor(private mediaCapture: MediaCapture) { }
CaptureMultiplePhotos(){
let options: CaptureImageOptions = { limit: 3 } // pass your limit for images
this.mediaCapture.captureImage(options)
.then(
(data: MediaFile[]) => {
console.log('Your Multiple Photos Array:', data)
},
(err: CaptureError) => console.error(err)
);
}
CodePudding user response:
.HTML
<ion-content [fullscreen]="true">
<ion-button color="primary" (click)="CaptureMultiplePhotos()">Scatta</ion-button>
</ion-content>
.TS
import { Component, NgZone } from '@angular/core';
import { MediaCapture, MediaFile, CaptureError, CaptureImageOptions } from '@ionic-native/media-capture/ngx';
@Component({
selector: 'app-home',
templateUrl: 'home.page.html',
styleUrls: ['home.page.scss'],
})
export class HomePage {
constructor(private mediaCapture: MediaCapture) {}
CaptureMultiplePhotos(){
const options: CaptureImageOptions = { limit: 3 }; // pass your limit for images
this.mediaCapture.captureImage(options)
.then(
(data: MediaFile[]) => {
console.log('Your Multiple Photos Array:', data);
},
(err: CaptureError) => console.error(err)
);
}
}