Created
October 14, 2018 06:51
-
-
Save apuravchauhan/02841f26a3629386ce9ba462e65b0686 to your computer and use it in GitHub Desktop.
Home component with camera preview plugin integrated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | |
}); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Follow this for more details:
https://ionicframework.com/docs/native/camera-preview/