我正在使用 angularjs 开发 Cordova ionic 应用程序。我使用 this plugin 作为相机功能。我正在尝试为图片和视频设置相机,但 问题是 :我只能拍照。摄像机不工作。我在 2 台三星设备(平板电脑和手机)上进行了尝试。
这是我的代码:(AngularJS)
var app = angular.module("app", ["ionic"]);
var controllerApp = function ($scope) {
$scope.message = "Its Works !";
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
console.log(navigator.camera);
}
$scope.getPic = function () {
navigator.camera.getPicture(onSuccess, onFail, {
quality: 25,
mediaType: Camera.MediaType.ALLMEDIA,
destinationType: Camera.DestinationType.DATA_URL,
});
function onSuccess(imageData) {
$scope.imgURI = "data:image/jpeg;base64," + imageData;
}
function onFail(message) {
alert('Failed because: ' + message);
}
}
};
app.controller("controllerApp", ["$scope", controllerApp]);
HTML
<div class="col col-40" ng-model="excercise.excerciseMedia">Set Media</div>
<button class="button button-dark col col-30 ion-camera" ng-click="getPic()">Camera</button>
<img ng-show="imgURI !== undefined" ng-src="{{imgURI}}" style="text-align: center">
我需要帮助: 相机应该记录照片和视频。现在只拍照片。
PICTURE: The Videocamera Button is not clickable
最佳答案
我还没有看这个应用程序的代码(它是一个 Ionic 2 应用程序,它只记录视频)但是你可以看看那里使用的插件以及它们是如何工作的(在 nexus 7 2013 上工作) .
https://github.com/rossmartin/video-editor-ionic2
这些是必需的插件:
cordova-plugin-camera
cordova-plugin-device
cordova-plugin-media-capture
https://github.com/driftyco/ionic-plugin-keyboard.git
cordova-plugin-statusbar
cordova-plugin-spinner-dialog
cordova-plugin-instagram-assets-picker
cordova-plugin-video-editor