mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 12:37:53 +00:00
some changes
This commit is contained in:
@@ -16,7 +16,7 @@ import { formatDate } from 'src/plugin/momentG.js'
|
||||
import { ThemeService } from 'src/app/services/theme.service';
|
||||
import { Camera, CameraResultType, CameraSource, Photo } from '@capacitor/camera';
|
||||
|
||||
import { Filesystem, Directory } from '@capacitor/filesystem';
|
||||
import { Filesystem, Directory, Encoding } from '@capacitor/filesystem';
|
||||
import { NgxImageCompressService } from "ngx-image-compress";
|
||||
import { HttpErrorHandle } from 'src/app/services/http-error-handle.service';
|
||||
import { PublicationFolderService } from 'src/app/store/publication-folder.service';
|
||||
@@ -27,6 +27,7 @@ import { FilePicker } from '@capawesome/capacitor-file-picker';
|
||||
import { CapacitorVideoPlayer } from 'capacitor-video-player';
|
||||
import { VideoRecorder, VideoRecorderCamera, VideoRecorderPreviewFrame } from '@teamhive/capacitor-video-recorder';
|
||||
import { CaptureImageOptions, MediaCapture } from '@awesome-cordova-plugins/media-capture/ngx';
|
||||
import { Capacitor } from '@capacitor/core';
|
||||
|
||||
const config = {
|
||||
quality: 0.5,
|
||||
@@ -108,6 +109,7 @@ export class NewPublicationPage implements OnInit {
|
||||
video: any;
|
||||
photoOrVideo: boolean = false;
|
||||
fileType = "";
|
||||
filecontent: boolean;
|
||||
|
||||
constructor(
|
||||
private modalController: ModalController,
|
||||
@@ -172,6 +174,7 @@ export class NewPublicationPage implements OnInit {
|
||||
0.9 // quality
|
||||
).then((picture) => {
|
||||
console.log('taked: ', picture)
|
||||
this.filecontent = true;
|
||||
this.capturedImage = picture
|
||||
this.photoOrVideo = false;
|
||||
|
||||
@@ -207,15 +210,27 @@ export class NewPublicationPage implements OnInit {
|
||||
this.video = data[0];
|
||||
console.log(this.video)
|
||||
this.fileType = "video/mp4"
|
||||
let resultUrl = decodeURIComponent(data[0].localURL);
|
||||
Filesystem.readFile({ path: resultUrl })
|
||||
await Filesystem.writeFile({
|
||||
path: data[0].name,
|
||||
data: data[0].fullPath,
|
||||
directory: Directory.Data,
|
||||
}).then((dir) => {
|
||||
console.log('DIR ', dir)
|
||||
let resultUrl = decodeURIComponent(dir.uri);
|
||||
Filesystem.readFile({ path: resultUrl, encoding: Encoding.UTF8, })
|
||||
|
||||
.then(async (content) => {
|
||||
console.log(JSON.stringify(content))
|
||||
const base64Data = btoa(content.data);
|
||||
|
||||
console.log(base64Data);
|
||||
/* this.filecontent = true;
|
||||
this.capturedVideo = "data:video/mp4;base64," + content.data;
|
||||
this.photoOrVideo = false; */
|
||||
})
|
||||
.catch((err) => console.error(err));
|
||||
});
|
||||
|
||||
.then(async (content) => {
|
||||
console.log(content)
|
||||
this.capturedVideo = "data:video/mp4;base64," + content.data;
|
||||
this.photoOrVideo = false;
|
||||
})
|
||||
.catch((err) => console.error(err));
|
||||
} catch (error) {
|
||||
console.log('record video error: ', error)
|
||||
}
|
||||
@@ -226,9 +241,9 @@ export class NewPublicationPage implements OnInit {
|
||||
async loadVideo() {
|
||||
|
||||
const result = await FilePicker.pickMedia
|
||||
({
|
||||
multiple: true,
|
||||
});
|
||||
({
|
||||
multiple: true,
|
||||
});
|
||||
let resultUrl = decodeURIComponent(result.files[0].path);
|
||||
this.fileType = result.files[0].mimeType
|
||||
Filesystem.readFile({ path: resultUrl })
|
||||
@@ -236,10 +251,11 @@ export class NewPublicationPage implements OnInit {
|
||||
.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;
|
||||
this.capturedVideo = "data:video/mp4;base64," + content.data;
|
||||
} else if (this.fileType == "image/jpg") {
|
||||
this.capturedVideo = "data:image/jpg;base64," +content.data;
|
||||
this.capturedVideo = "data:image/jpg;base64," + content.data;
|
||||
}
|
||||
})
|
||||
.catch((err) => console.error(err));
|
||||
|
||||
Reference in New Issue
Block a user