mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 12:37:53 +00:00
fix open shared publication folder
This commit is contained in:
@@ -31,6 +31,7 @@ def capacitor_pods
|
||||
pod 'CapacitorVoiceRecorder', :path => '../../node_modules/capacitor-voice-recorder'
|
||||
pod 'SendIntent', :path => '../../node_modules/send-intent'
|
||||
pod 'CordovaPlugins', :path => '../capacitor-cordova-ios-plugins'
|
||||
pod 'CordovaPluginsStatic', :path => '../capacitor-cordova-ios-plugins'
|
||||
pod 'CordovaPluginsResources', :path => '../capacitor-cordova-ios-plugins'
|
||||
end
|
||||
|
||||
|
||||
Generated
+31
-23
@@ -29,6 +29,7 @@
|
||||
"@angular/router": "~12.1.2",
|
||||
"@awesome-cordova-plugins/core": "^5.40.0",
|
||||
"@awesome-cordova-plugins/document-viewer": "^5.41.0",
|
||||
"@awesome-cordova-plugins/ffmpeg": "^6.6.0",
|
||||
"@awesome-cordova-plugins/file": "^5.41.0",
|
||||
"@awesome-cordova-plugins/file-opener": "^5.41.0",
|
||||
"@awesome-cordova-plugins/media-capture": "^6.4.0",
|
||||
@@ -116,6 +117,7 @@
|
||||
"cordova": "^11.0.0",
|
||||
"cordova-plugin-crop": "^0.4.0",
|
||||
"cordova-plugin-document-viewer": "^1.0.0",
|
||||
"cordova-plugin-ffmpeg": "github:MaximBelov/cordova-plugin-ffmpeg",
|
||||
"cordova-plugin-file": "^6.0.2",
|
||||
"cordova-plugin-file-opener2": "^3.0.5",
|
||||
"cordova-plugin-file-transfer": "github:apache/cordova-plugin-file-transfer",
|
||||
@@ -206,7 +208,6 @@
|
||||
"cordova-plugin-androidx-adapter": "^1.1.3",
|
||||
"cordova-plugin-device": "^2.0.2",
|
||||
"cordova-plugin-dialogs": "^2.0.2",
|
||||
"cordova-plugin-fingerprint-aio": "^4.0.2",
|
||||
"cordova-plugin-globalization": "^1.11.0",
|
||||
"cordova-plugin-inappbrowser": "^4.0.0",
|
||||
"cordova-plugin-media": "^5.0.4",
|
||||
@@ -1869,6 +1870,18 @@
|
||||
"rxjs": "^5.5.0 || ^6.5.0 || ^7.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@awesome-cordova-plugins/ffmpeg": {
|
||||
"version": "6.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@awesome-cordova-plugins/ffmpeg/-/ffmpeg-6.6.0.tgz",
|
||||
"integrity": "sha512-Js27Q1+ehahZddmsrpewq6Luo7yunNQwSWDlKZEb/HXxzBe/mXXJQI0W1BgL2IZkG/PGsoR1Vqk65WhV/+1ZSA==",
|
||||
"dependencies": {
|
||||
"@types/cordova": "latest"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@awesome-cordova-plugins/core": "^6.0.1",
|
||||
"rxjs": "^5.5.0 || ^6.5.0 || ^7.3.0"
|
||||
}
|
||||
},
|
||||
"node_modules/@awesome-cordova-plugins/file": {
|
||||
"version": "5.41.0",
|
||||
"resolved": "https://registry.npmjs.org/@awesome-cordova-plugins/file/-/file-5.41.0.tgz",
|
||||
@@ -12703,6 +12716,11 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"node_modules/cordova-plugin-ffmpeg": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "git+ssh://git@github.com/MaximBelov/cordova-plugin-ffmpeg.git#535a64e437f81b34bacf090da7fc97e6754189c7",
|
||||
"license": "Apache-2"
|
||||
},
|
||||
"node_modules/cordova-plugin-file": {
|
||||
"version": "6.0.2",
|
||||
"resolved": "https://registry.npmjs.org/cordova-plugin-file/-/cordova-plugin-file-6.0.2.tgz",
|
||||
@@ -12745,22 +12763,6 @@
|
||||
"integrity": "sha512-DwKuH5tXhZJImU/rHDzQhG3bY2ihAUw5QqdNllso96MZ9TQTAbFvKPLppuJwx21XxYS2g3uB9R17AXEEme+sKA==",
|
||||
"deprecated": "No longer maintained"
|
||||
},
|
||||
"node_modules/cordova-plugin-fingerprint-aio": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/cordova-plugin-fingerprint-aio/-/cordova-plugin-fingerprint-aio-4.0.2.tgz",
|
||||
"integrity": "sha512-Mmm/Ee85s4JH7qL3yikQ2J2I2vY2XbNi1fttoEK2kI++YHr/WeqPHWGREFL7bmFYjZTph/JovhfWHPGV924WjQ==",
|
||||
"dev": true,
|
||||
"engines": {
|
||||
"cordovaDependencies": {
|
||||
">=3.0.0": {
|
||||
"cordova-android": ">=8.0.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"funding": {
|
||||
"url": "https://github.com/sponsors/NiklasMerz"
|
||||
}
|
||||
},
|
||||
"node_modules/cordova-plugin-globalization": {
|
||||
"version": "1.11.0",
|
||||
"resolved": "https://registry.npmjs.org/cordova-plugin-globalization/-/cordova-plugin-globalization-1.11.0.tgz",
|
||||
@@ -45037,6 +45039,14 @@
|
||||
"@types/cordova": "latest"
|
||||
}
|
||||
},
|
||||
"@awesome-cordova-plugins/ffmpeg": {
|
||||
"version": "6.6.0",
|
||||
"resolved": "https://registry.npmjs.org/@awesome-cordova-plugins/ffmpeg/-/ffmpeg-6.6.0.tgz",
|
||||
"integrity": "sha512-Js27Q1+ehahZddmsrpewq6Luo7yunNQwSWDlKZEb/HXxzBe/mXXJQI0W1BgL2IZkG/PGsoR1Vqk65WhV/+1ZSA==",
|
||||
"requires": {
|
||||
"@types/cordova": "latest"
|
||||
}
|
||||
},
|
||||
"@awesome-cordova-plugins/file": {
|
||||
"version": "5.41.0",
|
||||
"resolved": "https://registry.npmjs.org/@awesome-cordova-plugins/file/-/file-5.41.0.tgz",
|
||||
@@ -53472,6 +53482,10 @@
|
||||
"resolved": "https://registry.npmjs.org/cordova-plugin-document-viewer/-/cordova-plugin-document-viewer-1.0.0.tgz",
|
||||
"integrity": "sha512-LQZiWVU543rLJ0wYoawSdMrAfoxBLWCx8a2CuQjFeav4U9CN16QAh1VHetHaHicp5ZEwTC7Zq/0TNbak6A7bVw=="
|
||||
},
|
||||
"cordova-plugin-ffmpeg": {
|
||||
"version": "git+ssh://git@github.com/MaximBelov/cordova-plugin-ffmpeg.git#535a64e437f81b34bacf090da7fc97e6754189c7",
|
||||
"from": "cordova-plugin-ffmpeg@https://github.com/MaximBelov/cordova-plugin-ffmpeg.git"
|
||||
},
|
||||
"cordova-plugin-file": {
|
||||
"version": "6.0.2",
|
||||
"resolved": "https://registry.npmjs.org/cordova-plugin-file/-/cordova-plugin-file-6.0.2.tgz",
|
||||
@@ -53492,12 +53506,6 @@
|
||||
"resolved": "https://registry.npmjs.org/cordova-plugin-filepath/-/cordova-plugin-filepath-1.6.0.tgz",
|
||||
"integrity": "sha512-DwKuH5tXhZJImU/rHDzQhG3bY2ihAUw5QqdNllso96MZ9TQTAbFvKPLppuJwx21XxYS2g3uB9R17AXEEme+sKA=="
|
||||
},
|
||||
"cordova-plugin-fingerprint-aio": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/cordova-plugin-fingerprint-aio/-/cordova-plugin-fingerprint-aio-4.0.2.tgz",
|
||||
"integrity": "sha512-Mmm/Ee85s4JH7qL3yikQ2J2I2vY2XbNi1fttoEK2kI++YHr/WeqPHWGREFL7bmFYjZTph/JovhfWHPGV924WjQ==",
|
||||
"dev": true
|
||||
},
|
||||
"cordova-plugin-globalization": {
|
||||
"version": "1.11.0",
|
||||
"resolved": "https://registry.npmjs.org/cordova-plugin-globalization/-/cordova-plugin-globalization-1.11.0.tgz",
|
||||
|
||||
+2
-1
@@ -43,6 +43,7 @@
|
||||
"@angular/router": "~12.1.2",
|
||||
"@awesome-cordova-plugins/core": "^5.40.0",
|
||||
"@awesome-cordova-plugins/document-viewer": "^5.41.0",
|
||||
"@awesome-cordova-plugins/ffmpeg": "^6.6.0",
|
||||
"@awesome-cordova-plugins/file": "^5.41.0",
|
||||
"@awesome-cordova-plugins/file-opener": "^5.41.0",
|
||||
"@awesome-cordova-plugins/media-capture": "^6.4.0",
|
||||
@@ -130,6 +131,7 @@
|
||||
"cordova": "^11.0.0",
|
||||
"cordova-plugin-crop": "^0.4.0",
|
||||
"cordova-plugin-document-viewer": "^1.0.0",
|
||||
"cordova-plugin-ffmpeg": "github:MaximBelov/cordova-plugin-ffmpeg",
|
||||
"cordova-plugin-file": "^6.0.2",
|
||||
"cordova-plugin-file-opener2": "^3.0.5",
|
||||
"cordova-plugin-file-transfer": "github:apache/cordova-plugin-file-transfer",
|
||||
@@ -220,7 +222,6 @@
|
||||
"cordova-plugin-androidx-adapter": "^1.1.3",
|
||||
"cordova-plugin-device": "^2.0.2",
|
||||
"cordova-plugin-dialogs": "^2.0.2",
|
||||
"cordova-plugin-fingerprint-aio": "^4.0.2",
|
||||
"cordova-plugin-globalization": "^1.11.0",
|
||||
"cordova-plugin-inappbrowser": "^4.0.0",
|
||||
"cordova-plugin-media": "^5.0.4",
|
||||
|
||||
@@ -28,6 +28,7 @@ import {MAT_DATE_LOCALE} from '@angular/material/core';
|
||||
import { Network } from '@ionic-native/network/ngx';
|
||||
import { MultipleDocumentsPicker } from '@awesome-cordova-plugins/multiple-document-picker/ngx';
|
||||
import { DocumentViewer } from '@awesome-cordova-plugins/document-viewer/ngx';
|
||||
import { FFMpeg } from '@awesome-cordova-plugins/ffmpeg/ngx';
|
||||
|
||||
|
||||
|
||||
@@ -213,6 +214,7 @@ import { FirebaseX } from '@ionic-native/firebase-x/ngx'; */
|
||||
NgxExtendedPdfViewerModule,
|
||||
FileOpener,
|
||||
DocumentViewer,
|
||||
FFMpeg,
|
||||
{ provide: HTTP_INTERCEPTORS, useClass: LoggingInterceptorService, multi: true },
|
||||
tokenInterceptor
|
||||
|
||||
|
||||
@@ -104,7 +104,8 @@ export class HomePage implements OnInit {
|
||||
public ActiveTabService: ActiveTabService,
|
||||
private RoleIdService: RoleIdService,
|
||||
private modalController: ModalController,
|
||||
private zone: NgZone
|
||||
private zone: NgZone,
|
||||
public alertController: AlertController,
|
||||
|
||||
// private ChunkService: ChunkService,
|
||||
// private StreamService: StreamService
|
||||
@@ -165,7 +166,11 @@ export class HomePage implements OnInit {
|
||||
}
|
||||
if (result.url) {
|
||||
window["sharedContent"] = result;
|
||||
this.zone.run(() => this.router.navigateByUrl("/home/publications"));
|
||||
this.zone.run(() => this.router.navigateByUrl("/home/publications")).then(() => {
|
||||
this.alertMessageSharerContent();
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}).catch(err => console.error(err));
|
||||
|
||||
@@ -410,4 +415,20 @@ export class HomePage implements OnInit {
|
||||
})
|
||||
}
|
||||
|
||||
alertMessageSharerContent() {
|
||||
this.alertController .create({
|
||||
header: 'Selecione uma acção para criar a publicação',
|
||||
message: '',
|
||||
buttons: [
|
||||
{
|
||||
text: 'Ok',
|
||||
handler: () => {
|
||||
}
|
||||
}
|
||||
]
|
||||
}).then(res => {
|
||||
res.present();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ import { checkFileTypeService } from 'src/app/services/checkFileType.service';
|
||||
import { FileValidatorService } from "src/app/services/file/file-validator.service"
|
||||
import { App } from '@capacitor/app';
|
||||
import { Router } from '@angular/router';
|
||||
import { VideoconvertService } from 'src/app/services/videoconvert.service'
|
||||
|
||||
|
||||
const config = {
|
||||
@@ -139,6 +140,7 @@ export class NewPublicationPage implements OnInit {
|
||||
public checkFileType: checkFileTypeService,
|
||||
private FileValidatorService: FileValidatorService,
|
||||
private router: Router,
|
||||
private videoconvertService: VideoconvertService
|
||||
) {
|
||||
|
||||
this.publicationType = this.navParams.get('publicationType');
|
||||
@@ -255,46 +257,9 @@ export class NewPublicationPage implements OnInit {
|
||||
|
||||
try {
|
||||
if (this.platform.is('ios')) {
|
||||
const result = await Filesystem.writeFile({
|
||||
path: 'video.mov',
|
||||
data: element.fullPath,
|
||||
directory: FilesystemDirectory.Data,
|
||||
encoding: FilesystemEncoding.UTF8
|
||||
})
|
||||
console.log('Wrote file', result);
|
||||
|
||||
Filesystem.readFile({ path: result.uri })
|
||||
|
||||
.then(async (content) => {
|
||||
console.log(content.data)
|
||||
this.filecontent = true;
|
||||
let fileObject = {
|
||||
FileBase64: 'data:video/mp4;base64,' + content.data,
|
||||
FileExtension: 'mp4',
|
||||
OriginalFileName: 'video'
|
||||
}
|
||||
this.seletedContent.push(fileObject)
|
||||
})
|
||||
.catch((err) => console.error(err));
|
||||
this.recordevideoIos(element.fullPath)
|
||||
} else {
|
||||
const savedFile = await Filesystem.copy({
|
||||
from: Capacitor.convertFileSrc(element.fullPath), // directory prop removed, Capacitor parses filename for us
|
||||
to: "video.mp4",
|
||||
toDirectory: FilesystemDirectory.Data
|
||||
});
|
||||
console.log(savedFile.uri)
|
||||
Filesystem.readFile({ path: savedFile.uri })
|
||||
|
||||
.then(async (content) => {
|
||||
this.filecontent = true;
|
||||
let fileObject = {
|
||||
FileBase64: 'data:video/mp4;base64,' + content.data,
|
||||
FileExtension: 'mp4',
|
||||
OriginalFileName: 'video'
|
||||
}
|
||||
this.seletedContent.push(fileObject)
|
||||
})
|
||||
.catch((err) => console.error(err));
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
@@ -583,7 +548,16 @@ export class NewPublicationPage implements OnInit {
|
||||
await this.publications.CreatePublication(this.folderId, this.publication).toPromise();
|
||||
this.httpErrorHandle.httpsSucessMessagge('Criar publicação')
|
||||
if (window["sharedContent"]) {
|
||||
|
||||
window["sharedContent"] = null
|
||||
window["openFolder"] = true
|
||||
|
||||
if(window.innerWidth <= 700) {
|
||||
this.router.navigate(['/home/publications', this.folderId]);
|
||||
} else if(window.innerWidth >= 701){
|
||||
this.router.navigate(['/home/publications?folderId='+this.folderId]);
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -842,5 +816,58 @@ export class NewPublicationPage implements OnInit {
|
||||
App.exitApp()
|
||||
}
|
||||
|
||||
async recordevideoIos(fullPath) {
|
||||
try {
|
||||
const directory = await Filesystem.getUri({
|
||||
directory: Directory.Cache,
|
||||
path: '',
|
||||
});
|
||||
|
||||
this.videoconvertService.convertVideo(fullPath,directory.uri,'mp4');
|
||||
|
||||
Filesystem.readFile({ path: `${directory.uri}output.mp4`})
|
||||
|
||||
.then(async (content) => {
|
||||
console.log(content.data)
|
||||
this.filecontent = true;
|
||||
let fileObject = {
|
||||
FileBase64: 'data:video/mp4;base64,' + content.data,
|
||||
FileExtension: 'mp4',
|
||||
OriginalFileName: 'video'
|
||||
}
|
||||
this.seletedContent.push(fileObject)
|
||||
})
|
||||
.catch((erro) => console.error('read converted video erro ', erro));
|
||||
} catch (error) {
|
||||
console.log('record video ios erro, ', error)
|
||||
}
|
||||
}
|
||||
|
||||
async recordVideoAndroid(fullPath) {
|
||||
try {
|
||||
const savedFile = await Filesystem.copy({
|
||||
from: Capacitor.convertFileSrc(fullPath),
|
||||
to: "video.mp4",
|
||||
toDirectory: FilesystemDirectory.Data
|
||||
});
|
||||
console.log(savedFile.uri)
|
||||
Filesystem.readFile({ path: savedFile.uri })
|
||||
|
||||
.then(async (content) => {
|
||||
this.filecontent = true;
|
||||
let fileObject = {
|
||||
FileBase64: 'data:video/mp4;base64,' + content.data,
|
||||
FileExtension: 'mp4',
|
||||
OriginalFileName: 'video'
|
||||
}
|
||||
this.seletedContent.push(fileObject)
|
||||
})
|
||||
.catch((error) => console.error('reade converted video erro ',error));
|
||||
|
||||
} catch (error) {
|
||||
console.log('record video android erro ', error)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { Router, NavigationEnd } from '@angular/router';
|
||||
import { ModalController, NavParams } from '@ionic/angular';
|
||||
import { AlertController, ModalController, NavParams } from '@ionic/angular';
|
||||
import { PublicationFolder } from 'src/app/models/publicationfolder';
|
||||
import { PublicationsService } from 'src/app/services/publications.service';
|
||||
import { NewActionPage } from './new-action/new-action.page';
|
||||
@@ -78,6 +78,7 @@ export class PublicationsPage implements OnInit {
|
||||
private StreamService:StreamService,
|
||||
private http: HttpClient,
|
||||
|
||||
|
||||
) {
|
||||
this.months = ["Janeiro", "Fevereiro", "Março", "Abril", "Maio", "Junho", "Julho", "Agosto", "Setembro", "Outubro", "Novembro", "Dezembro"];
|
||||
this.days = ["Domingo", "Segunda-feira", "Terça-feira", "Quarta-feira", "Quinta-feira", "Sexta-feira", "Sábado"];
|
||||
@@ -87,14 +88,30 @@ export class PublicationsPage implements OnInit {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
checkQueryParameter() {
|
||||
var urlSearchParams = new URLSearchParams(window.location.search);
|
||||
var folderId = urlSearchParams.get('folderId');
|
||||
|
||||
if (folderId !== null && window["openFolder"]) {
|
||||
window["openFolder"] = false
|
||||
this.goToPublicationsList(folderId)
|
||||
} else {
|
||||
console.log('Folder ID::', folderId);
|
||||
}
|
||||
}
|
||||
|
||||
ngOnInit() {
|
||||
|
||||
const pathname = window.location.pathname
|
||||
this.getActions();
|
||||
this.checkQueryParameter()
|
||||
|
||||
this.router.events.forEach((event) => {
|
||||
if (event instanceof NavigationEnd && event.url == pathname) {
|
||||
this.getActions();
|
||||
this.checkQueryParameter()
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ export class checkFileTypeService {
|
||||
const imageExtensions = ['jpg', 'jpeg', 'png', 'gif', 'bmp','tiff','tif',
|
||||
'image/jpg', 'image/jpeg', 'image/png', 'image/gif', 'image/bmp','image/tiff','image/tif', 'image/*']; // Add more if needed
|
||||
const videoExtensions = ['mp4', 'webm', 'mpg', 'mpeg', 'ogg',
|
||||
'video/mp4', 'video/webm', 'video/mpg', 'video/mpeg', 'video/ogg','video/quicktime','video/mov', 'video/*']; // Add more if needed
|
||||
'video/mp4', 'video/webm', 'video/mpg', 'video/mpeg', 'video/ogg','video/quicktime', 'video/*']; // Add more if needed
|
||||
|
||||
// Check if it's an image
|
||||
if (imageExtensions.includes(lowerCaseType)) {
|
||||
|
||||
@@ -2,14 +2,17 @@ import { Filesystem } from '@capacitor/filesystem';
|
||||
import { SendIntent } from "send-intent";
|
||||
import { Router } from '@angular/router';
|
||||
import { CallbackScheduler } from './callbackScheduler';
|
||||
import { AlertController, Platform } from '@ionic/angular';
|
||||
|
||||
export class SendIntentService {
|
||||
|
||||
Router!: Router
|
||||
|
||||
callbackScheduler = new CallbackScheduler()
|
||||
alertController = new AlertController()
|
||||
|
||||
constructor() {
|
||||
constructor(
|
||||
) {
|
||||
|
||||
SendIntent.checkSendIntentReceived().then((result: any) => {
|
||||
// logger
|
||||
@@ -36,11 +39,32 @@ export class SendIntentService {
|
||||
|
||||
|
||||
private onReceive = this.callbackScheduler.function<any>((result)=> {
|
||||
this.Router.navigateByUrl("/home/publications");
|
||||
this.Router.navigateByUrl("/home/publications").then(() => {
|
||||
if(Platform.prototype.is('ios')) {
|
||||
this.alertIos();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
window["sharedContent"] = result;
|
||||
})
|
||||
|
||||
private alertIos() {
|
||||
this.alertController .create({
|
||||
header: 'Selecione uma acção para criar a publicação',
|
||||
message: '',
|
||||
buttons: [
|
||||
{
|
||||
text: 'Ok',
|
||||
handler: () => {
|
||||
}
|
||||
}
|
||||
]
|
||||
}).then(res => {
|
||||
res.present();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export const sendIntent = new SendIntentService()
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
|
||||
import { VideoconvertService } from './videoconvert.service';
|
||||
|
||||
describe('VideoconvertService', () => {
|
||||
let service: VideoconvertService;
|
||||
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({});
|
||||
service = TestBed.inject(VideoconvertService);
|
||||
});
|
||||
|
||||
it('should be created', () => {
|
||||
expect(service).toBeTruthy();
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,20 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { FFMpeg } from '@awesome-cordova-plugins/ffmpeg/ngx';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class VideoconvertService {
|
||||
|
||||
constructor(
|
||||
private ffmpeg: FFMpeg
|
||||
) { }
|
||||
|
||||
async convertVideo(inputPath, outputPath, formart) {
|
||||
const ffmpegCommand = `-i "${inputPath}" -c:v copy -c:a aac -strict experimental "${outputPath}output.${formart}"`;
|
||||
|
||||
const result = await this.ffmpeg.exec(ffmpegCommand)
|
||||
|
||||
console.log('Convert returns ', `${outputPath}output.${formart}`);
|
||||
}
|
||||
}
|
||||
@@ -18,10 +18,11 @@ import { SocketConnectionMCRService } from "src/app/services/socket-connection-m
|
||||
import { CMAPIService } from '../../repository/CMAPI/cmapi.service';
|
||||
import { environment } from 'src/environments/environment';
|
||||
import { CaptureImageOptions, MediaCapture } from '@awesome-cordova-plugins/media-capture/ngx';
|
||||
import { Filesystem, FilesystemDirectory } from '@capacitor/filesystem';
|
||||
import { Directory, Filesystem, FilesystemDirectory } from '@capacitor/filesystem';
|
||||
import { Platform } from '@ionic/angular';
|
||||
import { PublicationAttachmentEntity, PublicationFormMV } from '../upload/upload-streaming.service';
|
||||
import { PublicationFormMVService } from "src/app/shared/publication/upload/publication-form-mv.service"
|
||||
import { VideoconvertService } from 'src/app/services/videoconvert.service';
|
||||
|
||||
enum ActionType {
|
||||
newRapid = "1",
|
||||
@@ -86,6 +87,7 @@ export class NewPublicationPage implements OnInit {
|
||||
private MiddlewareServiceService: MiddlewareServiceService,
|
||||
private LakefsRepositoryService: LakefsRepositoryService,
|
||||
private SocketConnectionMCRService: SocketConnectionMCRService,
|
||||
private videoconvertService: VideoconvertService
|
||||
) {
|
||||
this.publicationTitle = 'Nova Publicação';
|
||||
}
|
||||
@@ -727,29 +729,11 @@ export class NewPublicationPage implements OnInit {
|
||||
data.forEach(async element => {
|
||||
this.filesSizeSum = this.filesSizeSum + element.size
|
||||
if (this.fileSizeToMB(this.filesSizeSum) <= 20) {
|
||||
const savedFile = await Filesystem.copy({
|
||||
from: element.fullPath, // directory prop removed, Capacitor parses filename for us
|
||||
to: "video.mp4",
|
||||
toDirectory: FilesystemDirectory.Data
|
||||
});
|
||||
console.log(savedFile.uri)
|
||||
Filesystem.readFile({ path: savedFile.uri })
|
||||
|
||||
.then(async (content) => {
|
||||
this.filecontent = true;
|
||||
console.log('', content)
|
||||
let fileObject = new PublicationAttachmentEntity({
|
||||
base64: content.data,
|
||||
extension: 'mp4',
|
||||
OriginalFileName: 'record',
|
||||
FileType: 'video'
|
||||
|
||||
}
|
||||
)
|
||||
this.publicationFormMV.form.Files.push(fileObject)
|
||||
})
|
||||
.catch((err) => console.error(err));
|
||||
if(this.platform.is('ios'))
|
||||
this.recordevideoIos(element.fullPath)
|
||||
} else {
|
||||
this.recordVideoPc(element.fullPath)
|
||||
|
||||
if (this.publicationFormMV.form.Files.length === 0)
|
||||
this.filesSizeSum = 0
|
||||
|
||||
@@ -771,6 +755,65 @@ export class NewPublicationPage implements OnInit {
|
||||
if (this.platform.is('desktop'))
|
||||
return true;
|
||||
}
|
||||
|
||||
async recordevideoIos(fullPath) {
|
||||
try {
|
||||
const directory = await Filesystem.getUri({
|
||||
directory: Directory.Cache,
|
||||
path: '',
|
||||
});
|
||||
|
||||
this.videoconvertService.convertVideo(fullPath,directory.uri,'mp4');
|
||||
|
||||
Filesystem.readFile({ path: `${directory.uri}output.mp4`})
|
||||
|
||||
.then(async (content) => {
|
||||
this.filecontent = true;
|
||||
console.log('', content)
|
||||
let fileObject = new PublicationAttachmentEntity({
|
||||
base64: content.data,
|
||||
extension: 'mp4',
|
||||
OriginalFileName: 'record',
|
||||
FileType: 'video'
|
||||
|
||||
}
|
||||
)
|
||||
this.publicationFormMV.form.Files.push(fileObject)
|
||||
})
|
||||
.catch((erro) => console.error('read converted video erro ', erro));
|
||||
} catch (error) {
|
||||
console.log('record video ios erro, ', error)
|
||||
}
|
||||
}
|
||||
|
||||
async recordVideoPc(fullPath) {
|
||||
try {
|
||||
const savedFile = await Filesystem.copy({
|
||||
from: fullPath, // directory prop removed, Capacitor parses filename for us
|
||||
to: "video.mp4",
|
||||
toDirectory: FilesystemDirectory.Data
|
||||
});
|
||||
console.log(savedFile.uri)
|
||||
Filesystem.readFile({ path: savedFile.uri })
|
||||
|
||||
.then(async (content) => {
|
||||
this.filecontent = true;
|
||||
console.log('', content)
|
||||
let fileObject = new PublicationAttachmentEntity({
|
||||
base64: content.data,
|
||||
extension: 'mp4',
|
||||
OriginalFileName: 'record',
|
||||
FileType: 'video'
|
||||
|
||||
}
|
||||
)
|
||||
this.publicationFormMV.form.Files.push(fileObject)
|
||||
})
|
||||
.catch((err) => console.error(err));
|
||||
} catch (error) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Environment } from './../app/models/envarioment'
|
||||
import { oaprDev } from './suport/oapr'
|
||||
// import { doneITDev } from './suport/doneIt'
|
||||
import { doneITDev } from './suport/doneIt'
|
||||
import { DevDev } from './suport/dev'
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user