I am building a camera app with ionic and the cordova-plugin-camera-preview ( https://github.com/cordova-plugin-camera-preview/cordova-plugin-camera-preview ) and need to record video. I have the preview setup in the app correctly with a simple record button on top I want to add video recording function to the plugin and being able to call
CameraPreview.startRecording
and CameraPreview.stopRecording
.
Added video recording functionality to the plugin for the android platform and added the exec
functions in CameraPreview.js
and the function signatures in CameraPreview.d.ts
.
In my home.page.ts
from my project, I am trying to call this.cameraPreview.startRecording()
and this.cameraPreview.stopRecording()
but when I run ionic cordova run android
I get the following error:
ERROR in src/app/home/home.page.ts:90:32 - error TS2339: Property 'startRecording' does not exist on type 'CameraPreview'.
90 this.cameraPreview.startRecording();
~~~~~~~~~~~~~~
src/app/home/home.page.ts:92:32 - errorgn TS2339: Property 'stopRecording' does not exist on type 'CameraPreview'.
92 this.cameraPreview.stopRecording();
~~~~~~~~~~~~~
[ERROR] An error occurred while running subprocess ng.
ng run app:ionic-cordova-build --platform=android exited with exit code 1.
Log.d()
function call and running adb logcat to find it). So the code is being added. npm install
after editing plugin node_modules
folder within my ionic project Let me know if you want to see any of the files I mentioned.
The problem has to do with editing the plugin I linked in the question and then using the functions I added to the plugin. I have added video recording functionality to the plugin: a startRecording function and stopRecording function (and other stuff for configuring the camera for video recording). My ionic app works fine with the camera-preview (runs on android device) but when I try and call the functions I added (startRecording and stopRecording) I get the error listed above.
You haven't made it clear from the question if you understand that you need to use Ionic Native plugin as well with this cordova plugin.
From the way that you're talking it sounds like you have copied individual bits of code into your project.
You need to use this with it:
The general setup instructions for Ionic Native are here:
But even if you have done, looking at the plugin you linked out to - there are no recording options with it.
It's the camera preview only. Have you mixed up your plugins?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.