gzgchzc的博客

gzgchzc的博客

ionic添加cordova插件-Capture

gzgchzc博客最新更新地址:http://blog.gzvtc.cc/

Capture
录音

cordova plugin add cordova-plugin-media-capture

Example

module.controller('MyCtrl', function($scope, $cordovaCapture) {

  $scope.captureAudio = function() {
    var options = { limit: 3, duration: 10 };

    $cordovaCapture.captureAudio(options).then(function(audioData) {
      // Success! Audio data is here
       /**
         * @return
         *  [
         {
             "name": "录音04.amr",
             "localURL": "cdvfile://localhost/persistent/record/recorder/%E5%BD%95%E9%9F%B304.amr",
             "type": "audio/amr",
             "lastModified": null,
             "lastModifiedDate": 1482823911000,
             "size": 2854,
             "start": 0,
             "end": 0,
             "fullPath": "file:///storage/sdcard0/record/recorder/%E5%BD%95%E9%9F%B304.amr"
         }
         ]
         */
    }, function(err) {
      // An error occurred. Show a message to the user
    });
  }

  $scope.captureImage = function() {
    var options = { limit: 3 };

    $cordovaCapture.captureImage(options).then(function(imageData) {
     /* @return
         * [
         {
             "name": "1482824131776.jpg",
             "localURL": "cdvfile://localhost/persistent/DCIM/Camera/1482824131776.jpg",
             "type": "image/jpeg",
             "lastModified": null,
             "lastModifiedDate": 1482824140000,
             "size": 2627657,
             "start": 0,
             "end": 0,
             "fullPath": "file:///storage/sdcard0/DCIM/Camera/1482824131776.jpg"
         }
         ]
         */
    }, function(err) {
      // An error occurred. Show a message to the user
    });
  }

  $scope.captureVideo = function() {
    var options = { limit: 3, duration: 15 };

    $cordovaCapture.captureVideo(options).then(function(videoData) {
        /**
         * @return
         * [
         {
             "name": "VID_20161227_153633.mp4",
             "localURL": "cdvfile://localhost/persistent/DCIM/Camera/VID_20161227_153633.mp4",
             "type": "video/mp4",
             "lastModified": null,
             "lastModifiedDate": 1482824196000,
             "size": 5671730,
             "start": 0,
             "end": 0,
             "fullPath": "file:///storage/sdcard0/DCIM/Camera/VID_20161227_153633.mp4"
         }
         ]
         */
    }, function(err) {
      // An error occurred. Show a message to the user
    });
  }

});
阅读更多
版权声明:本文为博主gzgchzc原创文章,转载必须注明出处。http://blog.gzvtc.cc/ https://blog.csdn.net/qq_33561700/article/details/53895583
文章标签: cordova ionic
个人分类: Ionic
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

不良信息举报

ionic添加cordova插件-Capture

最多只允许输入30个字

加入CSDN,享受更精准的内容推荐,与500万程序员共同成长!
关闭
关闭