2
votes

I'm trying to let the user record a video within my Ionic app. I have looked into several plugins, such as cordova-plugin-camera, media-capture and video-capture-plus. But these all open up the device's camera application and return the video. That's not what I need.

I've also looked into camera-preview, which does let me see the camera view within my app, but it doesn't let me record video.

Is anyone aware of any other plugin that does allow me to record video, without having to open an external app?

If not, what would be some good key words to start researching to make this myself. Considering camera-preview shows the camera feed I feel like it has to be possible, even if the appropriate plugin doesn't exist yet.

Edit: The solution needs to work on iOS as well as Android

1

1 Answers

1
votes

You can use phonegap-plugin-media-recorder

It uses getUserMedia, with that you can set the camera feed to a video tag, and then record that feed.

The video tag will only work in Android, on iOS it will use the camera component to record the video.

navigator.mediaDevices.getUserMedia({
    'audio': true,
    'video': {
        facingMode: 'user'
    }
}).then(function(mediastream) {
    var options = { mimeType : 'video/quicktime'};
    var mediaRecorder = new MediaRecorder(mediastream, options);
});