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) {
|
async recordevideoIos(fullPath) {
|
||||||
|
console.log('fullpath', fullPath)
|
||||||
try {
|
try {
|
||||||
const directory = await Filesystem.getUri({
|
const directory = await Filesystem.getUri({
|
||||||
directory: Directory.Cache,
|
directory: Directory.Cache,
|
||||||
path: '',
|
path: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const stringGerada = this.gerarStringAleatoria();
|
||||||
|
console.log(stringGerada);
|
||||||
let fileObject ={};
|
let fileObject ={};
|
||||||
this.videoconvertService.convertVideo(fullPath,directory.uri,'mp4').then(() => {
|
this.videoconvertService.convertVideo(fullPath,directory.uri,stringGerada,'mp4').then(async () => {
|
||||||
Filesystem.readFile({ path: `${directory.uri}output.mp4`})
|
await Filesystem.readFile({ path: `${directory.uri}${stringGerada}.mp4`})
|
||||||
|
|
||||||
.then(async (content) => {
|
.then(async (content) => {
|
||||||
console.log(content.data)
|
|
||||||
this.filecontent = true;
|
this.filecontent = true;
|
||||||
fileObject = {
|
fileObject = {
|
||||||
FileBase64: 'data:video/mp4;base64,' + content.data,
|
FileBase64: 'data:video/mp4;base64,' + content.data,
|
||||||
@@ -822,6 +824,7 @@ export class NewPublicationPage implements OnInit {
|
|||||||
OriginalFileName: 'video'
|
OriginalFileName: 'video'
|
||||||
}
|
}
|
||||||
this.seletedContent.push(fileObject)
|
this.seletedContent.push(fileObject)
|
||||||
|
console.log('file object 1',fileObject)
|
||||||
fileObject ={};
|
fileObject ={};
|
||||||
const deleteSecretFile = async () => {
|
const deleteSecretFile = async () => {
|
||||||
await Filesystem.deleteFile({
|
await Filesystem.deleteFile({
|
||||||
@@ -829,9 +832,10 @@ export class NewPublicationPage implements OnInit {
|
|||||||
directory: Directory.Cache,
|
directory: Directory.Cache,
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
deleteSecretFile().then((value) => {
|
await deleteSecretFile().then((value) => {
|
||||||
console.log('delete file',value)
|
console.log('delete file',value)
|
||||||
fileObject ={};
|
fileObject ={};
|
||||||
|
console.log('file object 2',fileObject)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.catch((erro) => console.error('read converted video erro ', erro));
|
.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
|
private ffmpeg: FFMpeg
|
||||||
) { }
|
) { }
|
||||||
|
|
||||||
async convertVideo(inputPath, outputPath, formart) {
|
async convertVideo(inputPath, outputPath,filename, formart) {
|
||||||
const ffmpegCommand = `-i "${inputPath}" -c:v copy -c:a aac -strict experimental "${outputPath}output.${formart}"`;
|
const ffmpegCommand = `-i "${inputPath}" -c:v copy -c:a aac -strict experimental "${outputPath}${filename}.${formart}"`;
|
||||||
|
|
||||||
const result = await this.ffmpeg.exec(ffmpegCommand)
|
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: '',
|
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`})
|
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