【发布时间】:2021-01-15 04:53:44
【问题描述】:
我正在开发 Cordova 应用程序,我需要在其中捕获视频或从图库中选择并将其上传到远程服务器。我已经捕获了视频,它的路径即将到来,但我无法看到带有 url 的视频,也无法将其发送到服务器
`
takeVideo() {
let options: CaptureVideoOptions = { limit: 1, duration: 15 }
this.mediaCapture.captureVideo(options)
.then(
(data: MediaFile[]) => {
// imageData is either a base64 encoded string or a file URI
// If it's base64 (DATA_URL):
// let base64Image = 'data:image/jpeg;base64,' + imageData;
// alert(data[0].fullPath)
// this.copyFileToLocalDir(data[0].fullPath);
alert(data[0].fullPath)
this.dispVideos.push(data[0].fullPath)
},
(err: CaptureError) => {
alert(err)
}
);
}
`
上传方式 upload method
html
<div *ngIf="dispVideos?.length > 0">
<video #myVideo preload="metadata" controls="false">
<source [src]="sanitizer.bypassSecurityTrustResourceUrl(dispVideos[0])" type="video/mp4">
</video>
</div>
【问题讨论】:
标签: javascript angular typescript cordova ionic-framework