mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
changes and changes
This commit is contained in:
@@ -29,7 +29,7 @@ import { CaptureError, CaptureImageOptions, MediaCapture, MediaFile } from '@awe
|
||||
import { Capacitor } from '@capacitor/core';
|
||||
import { File } from '@ionic-native/file/ngx';
|
||||
import { Media } from '@ionic-native/media/ngx';
|
||||
|
||||
import { checkFileTypeService } from 'src/app/services/checkFileType.service';
|
||||
const config = {
|
||||
quality: 0.5,
|
||||
maxWidth: 800,
|
||||
@@ -111,6 +111,9 @@ export class NewPublicationPage implements OnInit {
|
||||
photoOrVideo: boolean = false;
|
||||
fileType = "";
|
||||
filecontent: boolean;
|
||||
seletedContent: any[] = []
|
||||
// Set a limit for the number of images to display
|
||||
displayLimit = 4;
|
||||
|
||||
constructor(
|
||||
private modalController: ModalController,
|
||||
@@ -126,7 +129,8 @@ export class NewPublicationPage implements OnInit {
|
||||
public PublicationFolderService: PublicationFolderService,
|
||||
private RouteService: RouteService,
|
||||
public FileService: FileService,
|
||||
private mediaCapture: MediaCapture
|
||||
private mediaCapture: MediaCapture,
|
||||
public checkFileType: checkFileTypeService
|
||||
) {
|
||||
|
||||
this.publicationType = this.navParams.get('publicationType');
|
||||
@@ -142,7 +146,27 @@ export class NewPublicationPage implements OnInit {
|
||||
ngOnInit() {
|
||||
if (this.intent) {
|
||||
this.filecontent = true
|
||||
this.capturedImage = 'data:image/jpeg;base64,' + this.intent;
|
||||
console.log(this.intent)
|
||||
if (this.checkFileType.checkFileType(this.intent.type) == 'image') {
|
||||
this.fileType = 'image'
|
||||
let resultUrl = decodeURIComponent(this.intent.url);
|
||||
Filesystem.readFile({ path: resultUrl }).then(async (content) => {
|
||||
this.capturedImage = 'data:image/jpeg;base64,' + content.data;
|
||||
console.log(this.capturedImage)
|
||||
})
|
||||
} else if (this.checkFileType.checkFileType(this.intent.type) == 'video') {
|
||||
this.fileType = 'video'
|
||||
let resultUrl = decodeURIComponent(this.intent.url);
|
||||
Filesystem.readFile({ path: resultUrl }).then(async (content) => {
|
||||
this.capturedVideo = "data:video/mp4;base64," + content.data;
|
||||
console.log(this.capturedVideo)
|
||||
})
|
||||
|
||||
} else {
|
||||
this.httpErrorHandle.validationMessagge('filetype');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
this.setTitle();
|
||||
@@ -171,7 +195,7 @@ export class NewPublicationPage implements OnInit {
|
||||
|
||||
this.capturedImage = 'data:image/jpeg;base64,' + capturedImage.base64String;
|
||||
this.capturedImageTitle = 'foto';
|
||||
this.fileType = "image/jpeg"
|
||||
this.fileType = "image"
|
||||
|
||||
const compressedImage = await this.compressImageBase64(
|
||||
this.capturedImage,
|
||||
@@ -211,7 +235,7 @@ export class NewPublicationPage implements OnInit {
|
||||
|
||||
async startVideoRecording() {
|
||||
try {
|
||||
let options: CaptureImageOptions = { limit: 1 }
|
||||
let options: CaptureImageOptions = { limit: 5 }
|
||||
const data = await this.mediaCapture.captureVideo(options)
|
||||
this.video = data[0];
|
||||
console.log(data)
|
||||
@@ -269,21 +293,31 @@ export class NewPublicationPage implements OnInit {
|
||||
({
|
||||
multiple: true,
|
||||
});
|
||||
let resultUrl = decodeURIComponent(result.files[0].path);
|
||||
this.fileType = result.files[0].mimeType
|
||||
Filesystem.readFile({ path: resultUrl })
|
||||
result.files.forEach(element => {
|
||||
|
||||
.then(async (content) => {
|
||||
console.log(result)
|
||||
console.log(content)
|
||||
this.filecontent = true;
|
||||
if (this.fileType == "video/mp4") {
|
||||
this.capturedVideo = "data:video/mp4;base64," + content.data;
|
||||
} else if (this.fileType == "image/jpg") {
|
||||
this.capturedVideo = "data:image/jpg;base64," + content.data;
|
||||
}
|
||||
})
|
||||
.catch((err) => console.error(err));
|
||||
let resultUrl = decodeURIComponent(element.path);
|
||||
this.fileType = element.mimeType
|
||||
Filesystem.readFile({ path: resultUrl })
|
||||
|
||||
.then(async (content) => {
|
||||
console.log(result)
|
||||
console.log(content)
|
||||
this.filecontent = true;
|
||||
let fileObject = {
|
||||
base64: content.data,
|
||||
fileType: this.fileType
|
||||
}
|
||||
this.seletedContent.push(fileObject)
|
||||
|
||||
if (this.fileType == "video") {
|
||||
this.capturedVideo = "data:video/mp4;base64," + content.data;
|
||||
} else if (this.fileType == "image") {
|
||||
this.capturedVideo = "data:image/jpg;base64," + content.data;
|
||||
}
|
||||
})
|
||||
.catch((err) => console.error(err));
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user