mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
fix publication OrifinalFilename
This commit is contained in:
@@ -1,19 +1,22 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { CaptureImageOptions, MediaCapture, MediaFile } from '@awesome-cordova-plugins/media-capture/ngx';
|
||||
import { Camera, CameraResultType, CameraSource, Photo} from '@capacitor/camera';
|
||||
|
||||
import { File } from "@awesome-cordova-plugins/file/ngx"
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class CameraService {
|
||||
|
||||
constructor() { }
|
||||
constructor(
|
||||
private mediaCapture: MediaCapture,
|
||||
private file: File) { }
|
||||
|
||||
|
||||
async takePicture(){
|
||||
async takePicture() {
|
||||
|
||||
return new Promise<Photo>(async (resolve, reject)=>{
|
||||
|
||||
|
||||
|
||||
|
||||
const image = await Camera.getPhoto({
|
||||
quality: 50,
|
||||
@@ -21,16 +24,38 @@ export class CameraService {
|
||||
resultType: CameraResultType.Uri,
|
||||
source: CameraSource.Camera // Camera, Photos or Prompt!
|
||||
});
|
||||
|
||||
|
||||
if (image) {
|
||||
resolve(image)
|
||||
|
||||
|
||||
} else {
|
||||
reject('Error saving image')
|
||||
}
|
||||
|
||||
|
||||
//this.capturedImage = this.capturedImage;
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
async startRecording() {
|
||||
try {
|
||||
let options: CaptureImageOptions = { limit: 1}
|
||||
|
||||
const data: MediaFile[] = (await this.mediaCapture.captureVideo(options) as any )
|
||||
const video = data[0]
|
||||
|
||||
let dir = video.fullPath.split("/")
|
||||
dir.pop()
|
||||
let fromDir = dir.join("/")
|
||||
let toDir = this.file.dataDirectory
|
||||
|
||||
const response = await this.file.copyFile(fromDir, video.name, toDir, video.name )
|
||||
console.log({response})
|
||||
|
||||
} catch(e) {
|
||||
console.log(e)
|
||||
}
|
||||
}
|
||||
|
||||
nice() {}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { CameraService } from './camera.service';
|
||||
|
||||
describe('CameraService', () => {
|
||||
let service: CameraService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(CameraService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,9 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class CameraService {
|
||||
|
||||
constructor() { }
|
||||
}
|
||||
Reference in New Issue
Block a user