mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
add generate string method
This commit is contained in:
@@ -803,18 +803,20 @@ export class NewPublicationPage implements OnInit {
|
||||
}
|
||||
|
||||
async recordevideoIos(fullPath) {
|
||||
console.log('fullpath', fullPath)
|
||||
try {
|
||||
const directory = await Filesystem.getUri({
|
||||
directory: Directory.Cache,
|
||||
path: '',
|
||||
});
|
||||
|
||||
const stringGerada = this.gerarStringAleatoria();
|
||||
console.log(stringGerada);
|
||||
let fileObject ={};
|
||||
this.videoconvertService.convertVideo(fullPath,directory.uri,'mp4').then(() => {
|
||||
Filesystem.readFile({ path: `${directory.uri}output.mp4`})
|
||||
this.videoconvertService.convertVideo(fullPath,directory.uri,stringGerada,'mp4').then(async () => {
|
||||
await Filesystem.readFile({ path: `${directory.uri}${stringGerada}.mp4`})
|
||||
|
||||
.then(async (content) => {
|
||||
console.log(content.data)
|
||||
this.filecontent = true;
|
||||
fileObject = {
|
||||
FileBase64: 'data:video/mp4;base64,' + content.data,
|
||||
@@ -822,6 +824,7 @@ export class NewPublicationPage implements OnInit {
|
||||
OriginalFileName: 'video'
|
||||
}
|
||||
this.seletedContent.push(fileObject)
|
||||
console.log('file object 1',fileObject)
|
||||
fileObject ={};
|
||||
const deleteSecretFile = async () => {
|
||||
await Filesystem.deleteFile({
|
||||
@@ -829,9 +832,10 @@ export class NewPublicationPage implements OnInit {
|
||||
directory: Directory.Cache,
|
||||
});
|
||||
};
|
||||
deleteSecretFile().then((value) => {
|
||||
await deleteSecretFile().then((value) => {
|
||||
console.log('delete file',value)
|
||||
fileObject ={};
|
||||
console.log('file object 2',fileObject)
|
||||
})
|
||||
})
|
||||
.catch((erro) => console.error('read converted video erro ', erro));
|
||||
@@ -901,5 +905,17 @@ export class NewPublicationPage implements OnInit {
|
||||
|
||||
}
|
||||
|
||||
gerarStringAleatoria() {
|
||||
const caracteres = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
let stringAleatoria = '';
|
||||
|
||||
for (let i = 0; i < 4; i++) {
|
||||
const indiceAleatorio = Math.floor(Math.random() * caracteres.length);
|
||||
stringAleatoria += caracteres.charAt(indiceAleatorio);
|
||||
}
|
||||
|
||||
return stringAleatoria;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -10,19 +10,12 @@ export class VideoconvertService {
|
||||
private ffmpeg: FFMpeg
|
||||
) { }
|
||||
|
||||
async convertVideo(inputPath, outputPath, formart) {
|
||||
const ffmpegCommand = `-i "${inputPath}" -c:v copy -c:a aac -strict experimental "${outputPath}output.${formart}"`;
|
||||
async convertVideo(inputPath, outputPath,filename, formart) {
|
||||
const ffmpegCommand = `-i "${inputPath}" -c:v copy -c:a aac -strict experimental "${outputPath}${filename}.${formart}"`;
|
||||
|
||||
const result = await this.ffmpeg.exec(ffmpegCommand)
|
||||
|
||||
console.log('Convert returns ', `${outputPath}output.${formart}`);
|
||||
console.log('Convert returns ', `${outputPath}${filename}.${formart}`);
|
||||
}
|
||||
|
||||
async convertVideoAndroid(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}`);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -763,7 +763,10 @@ export class NewPublicationPage implements OnInit {
|
||||
path: '',
|
||||
});
|
||||
|
||||
this.videoconvertService.convertVideo(fullPath,directory.uri,'mp4');
|
||||
const stringGerada = this.gerarStringAleatoria();
|
||||
console.log(stringGerada);
|
||||
|
||||
this.videoconvertService.convertVideo(fullPath,directory.uri,stringGerada,'mp4');
|
||||
|
||||
Filesystem.readFile({ path: `${directory.uri}output.mp4`})
|
||||
|
||||
@@ -814,6 +817,18 @@ export class NewPublicationPage implements OnInit {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
gerarStringAleatoria() {
|
||||
const caracteres = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
|
||||
let stringAleatoria = '';
|
||||
|
||||
for (let i = 0; i < 4; i++) {
|
||||
const indiceAleatorio = Math.floor(Math.random() * caracteres.length);
|
||||
stringAleatoria += caracteres.charAt(indiceAleatorio);
|
||||
}
|
||||
|
||||
return stringAleatoria;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user