有人可以帮助我找到我能找到的地方或告诉我如何实现离子2打字稿的视频捕捉。
我知道拍照很简单,但他们没有关于如何拍摄视频的明确文件
答案 0 :(得分:1)
您可以使用the Media Capture plugin
要查看完整文档,您应该检查插件的git repo。
很简单,他们提供了captureImage示例,只需使用captureVideo(options)
方法,您可以在文档中找到选项(git repo docs),参见“CaptureVideoOptions”' ,你有限制和持续时间选项。
答案 1 :(得分:0)
安装Cordova和Ionic Native插件:
ionic cordova plugin add cordova-plugin-media-capture
npm install --save @ionic-native/media-capture
videoplayer.html
<ion-content padding>
<button ion-button (click)="startrecording()">Start Video
Recording</button>
<button ion-button (click)="selectvideo()">Select Video From
Gallery</button>
<video #myvideo height="300" width="300" controls></video>
</ion-content>
videoplayer.ts
import { MediaCapture, MediaFile, CaptureError, CaptureImageOptions } from '@ionic-native/media-capture';
import { Camera } from "@ionic-native/camera";
.......
@ViewChild('myvideo') myVideo: any;
......
constructor(public camera:Camera, private mediaCapture: MediaCapture)
{}
startrecording() {
this.mediaCapture.captureVideo((videodata) => {
alert(JSON.stringify(videodata));
})
}
selectvideo() {
let video = this.myVideo.nativeElement;
var options = {
sourceType: 2,
mediaType: 1
};
this.camera.getPicture(options).then((data) => {
video.src = data;
video.play();
})
}
}
来源:http://tphangout.com/ionic-2-video-capture-and-playback/ https://ionicframework.com/docs/native/media-capture/