l am try to upload videos to firebase storage using angular2fire and media capture plugin , VideoEditor plugin and Diagnostic plugin to check permissions .
l have succeeded video capture and resize video using video editor plugin . But when l pass the url of video to method of upload . l got error
Path of video without using video editor plugin for resize .
Path of video when using video editor plugin for resize .
when l passed the url of both of them l got same error above.
Full code
//check permission for taken vid
capturevideo() {
this.diagnostic.isCameraAuthorized().then((authorized) => {
if (authorized) {
this.capturingVideo();
}
else {
this.diagnostic.requestCameraAuthorization().then(async (status) => {
if (status == this.diagnostic.permissionStatus.GRANTED) {
this.capturingVideo()
}
else {
//Permissions not granted
//Therefore, create and present toast
const a = await this.a.create({
backdropDismiss: false,
cssClass: 'my-custom-class',
message: 'Need permission',
buttons: [
{
text: 'الغاء',
},
{
text: 'الاعدادت',
handler: () => {
this.diagnostic.switchToSettings();
}
}
]
})
a.present()
}
});
}
});
}
// takes vid
capturingVideo() {
let options: CaptureVideoOptions = { limit: 1, duration: 15, quality: 40 }
this.mediaCapture.captureVideo(options)
.then(
(data: MediaFile[]) => {
//console.log(data)
data.forEach(async a => {
alert(a.fullPath)
// resize video
this.videoEditor.transcodeVideo({
fileUri: a.fullPath,
outputFileName: 'output',
outputFileType: this.videoEditor.OutputFileType.MPEG4,
width: 640, // optional, see note below on width and height
height: 640, // optional, see notes below on width and height
}) .then((fileUri) => {
alert(fileUri);
this.upload_video(fileUri);
})
.catch((error: any) => console.log('video transcode error', error));
})
},
(err: CaptureError) => alert('video transcode error' + err)
);
}
// then upload video
async upload_video(event) {
let uid = localStorage.getItem('uid')
this.loading = await this.l.create({
message: 'يرجى الانتظار , جاري الرفع',
cssClass: 'with-progress',
backdropDismiss: false,
});
this.loading.present();
// The storage path
const id = "incident/videos/" + uid + "/" + Math.random().toString(36).substring(2);
//File reference
const fileRef = this.afStorage.ref(id);
// The main task
fileRef.putString(event,'data_url', { contentType: 'video/mp4'}).percentageChanges().subscribe(a => {
this.precent = a.toFixed();
this.loading.style.setProperty('--percent-uploaded', `${a.toFixed()}%`)
fileRef.getDownloadURL().subscribe(async url => {
this.data.imageurl.push(url);
this.loading.dismiss();
let t = await this.t.create({
message: 'تم الرفع بنجاح',
color: 'success',
cssClass: 'toast',
duration: 1000
});
t.present();
//this.r.navigate(['tabs/tab3'])
})
})
}
l have already used this.webview.convertFileSrc(url)
. But l got same error .
Any solution please ?