Skip to content

Instantly share code, notes, and snippets.

@apuravchauhan
Created October 14, 2018 06:51
Show Gist options
  • Save apuravchauhan/02841f26a3629386ce9ba462e65b0686 to your computer and use it in GitHub Desktop.
Save apuravchauhan/02841f26a3629386ce9ba462e65b0686 to your computer and use it in GitHub Desktop.
Home component with camera preview plugin integrated.
import { Component } from '@angular/core';
import { NavController,Platform } from 'ionic-angular';
import { CameraPreview, CameraPreviewOptions } from '@ionic-native/camera-preview';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(private platform:Platform,private cameraPreview: CameraPreview,public navCtrl: NavController) {
const cameraPreviewOpts: CameraPreviewOptions = {
x: 0,
y: 0,
width: window.screen.width,
height: window.screen.height,
camera: 'rear',
tapPhoto: true,
previewDrag: true,
toBack: true,
alpha: 1
};
this.platform.ready().then((readySource) => {
// start camera
this.cameraPreview.startCamera(cameraPreviewOpts).then(
(res) => {
console.log('Got Camera access ',res)
},
(err) => {
console.log('Problem accessing camera',err)
});
});
}
}
@apuravchauhan
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment