我正在使用cordova Media Capture插件,但没有可能使其工作,我无法解决它。
错误:TypeError: Cannot read property 'capture' of undefined
所以这是我用于我的Ionic应用程序的控制器,到目前为止似乎没有任何工作。有什么想法吗?
.controller('recordController', ['$scope', '$timeout', '$state', '$document', '$firebaseArray', 'CONFIG', function($scope, $timeout, $state, $document, $firebaseArray, CONFIG) {
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
console.log(navigator.device.capture);
}
var captureSuccess = function(e) {
console.log('captureSuccess');console.dir(e);
$scope.sound.file = e[0].localURL;
$scope.sound.filePath = e[0].fullPath;
}
$scope.recordAudio = function() {
navigator.device.capture.captureAudio(
captureSuccess,captureError,{duration:10});
}
var a = document.getElementById('tags');
a.addEventListener('keyup',addthis);
function addthis() {
b = a.value.replace('#','');
a.value = '#'+b
if (a.value.indexOf(' '))
{
a.value = a.value.replace(' ','#');
}
}
}])
答案 0 :(得分:0)
尝试安装设备插件,
cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git