mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-19 04:57:52 +00:00
Merge branch 'feature/viewer-attachment' of https://bitbucket.org/equilibriumito/gabinete-digital-fo into feature/viewer-attachment
This commit is contained in:
@@ -44,7 +44,7 @@
|
||||
(click)="imageSize(capturedImage)" style="height: 69px;"></ion-img>
|
||||
|
||||
<video *ngIf="checkFileType.checkFileType(seleted.FileExtension) == 'video'" width="70" height="70"
|
||||
controls="controls" preload="metadata" autoplay="autoplay" webkit-playsinline="webkit-playsinline">
|
||||
controls="controls" preload="metadata" webkit-playsinline="webkit-playsinline">
|
||||
<source type="video/mp4" [src]="seleted.FileBase64">
|
||||
</video>
|
||||
|
||||
|
||||
@@ -250,8 +250,6 @@ export class NewPublicationPage implements OnInit {
|
||||
this.video = data[0];
|
||||
console.log('video record', data)
|
||||
data.forEach(async element => {
|
||||
Capacitor.convertFileSrc(element.fullPath);
|
||||
console.log('convert url', (Capacitor.convertFileSrc(element.fullPath)));
|
||||
this.filesSizeSum = this.filesSizeSum + element.size
|
||||
if (this.fileSizeToMB(this.filesSizeSum) <= 20) {
|
||||
|
||||
@@ -286,7 +284,7 @@ export class NewPublicationPage implements OnInit {
|
||||
multiple: true,
|
||||
});
|
||||
console.log(result.files)
|
||||
result.files.forEach(element => {
|
||||
result.files.forEach(async element => {
|
||||
|
||||
this.filesSizeSum = this.filesSizeSum + element.size
|
||||
if (this.fileSizeToMB(this.filesSizeSum) <= 20) {
|
||||
@@ -296,30 +294,13 @@ export class NewPublicationPage implements OnInit {
|
||||
console.log('pass type verification ', resultUrl)
|
||||
|
||||
try {
|
||||
Filesystem.readFile({ path: resultUrl })
|
||||
|
||||
.then(async (content) => {
|
||||
console.log(result)
|
||||
console.log(content)
|
||||
this.filecontent = true;
|
||||
let fileObject;
|
||||
if (this.removeTextBeforeSlash(element.mimeType, '/') == "mp4") {
|
||||
fileObject = {
|
||||
FileBase64: 'data:video/mp4;base64,' + content.data,
|
||||
FileExtension: this.removeTextBeforeSlash(element.mimeType, '/'),
|
||||
OriginalFileName: 'video'
|
||||
}
|
||||
} else {
|
||||
fileObject = {
|
||||
FileBase64: content.data,
|
||||
FileExtension: this.removeTextBeforeSlash(element.mimeType, '/'),
|
||||
OriginalFileName: 'image'
|
||||
}
|
||||
}
|
||||
if(this.platform.is('ios')) {
|
||||
this.recordevideoIos(resultUrl)
|
||||
} else {
|
||||
this.loadVideoAndroid(resultUrl,element)
|
||||
}
|
||||
|
||||
this.seletedContent.push(fileObject)
|
||||
})
|
||||
.catch((err) => console.error(err));
|
||||
} catch (error) {
|
||||
console.log('upload video error: ', error)
|
||||
}
|
||||
@@ -813,8 +794,12 @@ export class NewPublicationPage implements OnInit {
|
||||
}
|
||||
|
||||
closeApp() {
|
||||
if (this.platform.is('android'))
|
||||
if (this.platform.is('android')) {
|
||||
App.exitApp()
|
||||
} else {
|
||||
window["sharedContent"] = null
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
async recordevideoIos(fullPath) {
|
||||
@@ -845,9 +830,10 @@ export class NewPublicationPage implements OnInit {
|
||||
}
|
||||
|
||||
async recordVideoAndroid(fullPath) {
|
||||
|
||||
try {
|
||||
const savedFile = await Filesystem.copy({
|
||||
from: Capacitor.convertFileSrc(fullPath),
|
||||
from: fullPath,
|
||||
to: "video.mp4",
|
||||
toDirectory: FilesystemDirectory.Data
|
||||
});
|
||||
@@ -870,5 +856,36 @@ export class NewPublicationPage implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
loadVideoIso() {
|
||||
|
||||
}
|
||||
|
||||
loadVideoAndroid(resultUrl,element) {
|
||||
Filesystem.readFile({ path: resultUrl })
|
||||
|
||||
.then(async (content) => {
|
||||
console.log(content)
|
||||
this.filecontent = true;
|
||||
let fileObject;
|
||||
if (this.removeTextBeforeSlash(element.mimeType, '/') == "mp4") {
|
||||
fileObject = {
|
||||
FileBase64: 'data:video/mp4;base64,' + content.data,
|
||||
FileExtension: this.removeTextBeforeSlash(element.mimeType, '/'),
|
||||
OriginalFileName: 'video'
|
||||
}
|
||||
} else {
|
||||
fileObject = {
|
||||
FileBase64: content.data,
|
||||
FileExtension: this.removeTextBeforeSlash(element.mimeType, '/'),
|
||||
OriginalFileName: 'image'
|
||||
}
|
||||
}
|
||||
|
||||
this.seletedContent.push(fileObject)
|
||||
})
|
||||
.catch((err) => console.error(err));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -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/*']; // Add more if needed
|
||||
'video/mp4', 'video/webm', 'video/mpg', 'video/mpeg', 'video/ogg','video/quicktime','MOV','mov', 'video/*']; // Add more if needed
|
||||
|
||||
// Check if it's an image
|
||||
if (imageExtensions.includes(lowerCaseType)) {
|
||||
|
||||
@@ -17,4 +17,12 @@ export class VideoconvertService {
|
||||
|
||||
console.log('Convert returns ', `${outputPath}output.${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}`);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user