mirror of
https://code.equilibrium.co.ao/ITO/doneit-web.git
synced 2026-04-18 20:47:54 +00:00
load video formated
This commit is contained in:
@@ -44,7 +44,7 @@
|
|||||||
(click)="imageSize(capturedImage)" style="height: 69px;"></ion-img>
|
(click)="imageSize(capturedImage)" style="height: 69px;"></ion-img>
|
||||||
|
|
||||||
<video *ngIf="checkFileType.checkFileType(seleted.FileExtension) == 'video'" width="70" height="70"
|
<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">
|
<source type="video/mp4" [src]="seleted.FileBase64">
|
||||||
</video>
|
</video>
|
||||||
|
|
||||||
|
|||||||
@@ -250,8 +250,6 @@ export class NewPublicationPage implements OnInit {
|
|||||||
this.video = data[0];
|
this.video = data[0];
|
||||||
console.log('video record', data)
|
console.log('video record', data)
|
||||||
data.forEach(async element => {
|
data.forEach(async element => {
|
||||||
Capacitor.convertFileSrc(element.fullPath);
|
|
||||||
console.log('convert url', (Capacitor.convertFileSrc(element.fullPath)));
|
|
||||||
this.filesSizeSum = this.filesSizeSum + element.size
|
this.filesSizeSum = this.filesSizeSum + element.size
|
||||||
if (this.fileSizeToMB(this.filesSizeSum) <= 20) {
|
if (this.fileSizeToMB(this.filesSizeSum) <= 20) {
|
||||||
|
|
||||||
@@ -286,7 +284,7 @@ export class NewPublicationPage implements OnInit {
|
|||||||
multiple: true,
|
multiple: true,
|
||||||
});
|
});
|
||||||
console.log(result.files)
|
console.log(result.files)
|
||||||
result.files.forEach(element => {
|
result.files.forEach(async element => {
|
||||||
|
|
||||||
this.filesSizeSum = this.filesSizeSum + element.size
|
this.filesSizeSum = this.filesSizeSum + element.size
|
||||||
if (this.fileSizeToMB(this.filesSizeSum) <= 20) {
|
if (this.fileSizeToMB(this.filesSizeSum) <= 20) {
|
||||||
@@ -296,30 +294,13 @@ export class NewPublicationPage implements OnInit {
|
|||||||
console.log('pass type verification ', resultUrl)
|
console.log('pass type verification ', resultUrl)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Filesystem.readFile({ path: resultUrl })
|
|
||||||
|
|
||||||
.then(async (content) => {
|
if(this.platform.is('ios')) {
|
||||||
console.log(result)
|
this.recordevideoIos(resultUrl)
|
||||||
console.log(content)
|
} else {
|
||||||
this.filecontent = true;
|
this.loadVideoAndroid(resultUrl,element)
|
||||||
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));
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log('upload video error: ', error)
|
console.log('upload video error: ', error)
|
||||||
}
|
}
|
||||||
@@ -845,9 +826,10 @@ export class NewPublicationPage implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async recordVideoAndroid(fullPath) {
|
async recordVideoAndroid(fullPath) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const savedFile = await Filesystem.copy({
|
const savedFile = await Filesystem.copy({
|
||||||
from: Capacitor.convertFileSrc(fullPath),
|
from: fullPath,
|
||||||
to: "video.mp4",
|
to: "video.mp4",
|
||||||
toDirectory: FilesystemDirectory.Data
|
toDirectory: FilesystemDirectory.Data
|
||||||
});
|
});
|
||||||
@@ -870,5 +852,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',
|
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
|
'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',
|
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
|
// Check if it's an image
|
||||||
if (imageExtensions.includes(lowerCaseType)) {
|
if (imageExtensions.includes(lowerCaseType)) {
|
||||||
|
|||||||
@@ -17,4 +17,12 @@ export class VideoconvertService {
|
|||||||
|
|
||||||
console.log('Convert returns ', `${outputPath}output.${formart}`);
|
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