我正在尝试使用TypeScript在Ionic 2应用中捕获视频。拍照很直接,看起来很容易。
Camera.getPicture({
destinationType: Camera.DestinationType.DATA_URL,
mediaType: Camera.MediaType.PICTURE,
targetHeight: 1000,
targetWidth: 1000
}).then((imageData) => {
this.base64Image = "data:image/jpeg;base64," + imageData;
}, (err) => {
console.log(err);
});
}
为了捕捉视频,我需要做出哪些更改?
答案 0 :(得分:1)
我没看过这个应用的代码,但你可以看看那里使用的插件及其工作原理(在nexus 7 2013上工作)。
https://github.com/rossmartin/video-editor-ionic2
这些是必需的插件:
GButton.setOnClickListener(new ImageButton.OnClickListener() {
public void onClick(View v) {
switch (v.getId()) {
case (R.id.blueButton):
Toast.makeText(MainActivity.this, "blue", Toast.LENGTH_SHORT).show();
GButton = (ImageButton) findViewById(R.id.redButton);
//ADD IT HERE
GButton.setOnClickListener(this);
break;
case (R.id.redButton):
Toast.makeText(MainActivity.this, "red", Toast.LENGTH_SHORT).show();
GButton = (ImageButton) findViewById(R.id.blueButton);
//ADD IT HERE
GButton.setOnClickListener(this);
break;
}
}
});
答案 1 :(得分:0)
您必须安装媒体捕获插件ionic plugin add cordova-plugin-media-capture
,然后安装angular typescript wrapper npm install --save @ionic-native/media-capture
import { MediaCapture, MediaFile } from '@ionic-native/media-capture'; // import the angular typescript classes from the installed wrapper
@Component(...)
export class Test{
constructor(private mediaCapture: MediaCapture) { } // inject the services in the constructor
this.mediaCapture.captureVideo().then((data: MediaFile[]) =>{
console.log(data) // data is the captured video file object
});
}
检查Ionic Doc是否有此插件https://ionicframework.com/docs/native/media-capture/