cordova插件- Media Capture

  • 添加插件

$ cordova plugin addcordova-plugin-media-capture

  • 插件的使用
  • Methods
  • capture.captureAudio
  • capture.captureImage
  • capture.captureVideo
  • Example

<div style="position: absolute;top: 40px"> <input type="button"value="captureAudio"onclick="captureAudioClik()"><br> <input type="button"value="captureImage"onclick="captureImageClik()"><br> <input type="button"value="captureVideo"onclick="captureVideoClik()"><br> <button onclick="javascript:history.back(-1)">返回上一页</button> </div> <script> // capture callback var captureSuccess=function(mediaFiles){ var i, path, len; for (i = 0, len =mediaFiles.length; i < len; i += 1) { path = mediaFiles[i].fullPath; // do something interestingwith the file console.log('path = '+path); } }; // capture error callback var captureError=function(error) { navigator.notification.alert('Error code:' +error.code, null, 'Capture Error'); }; //音频的捕获 function captureAudioClik() { // start audio capture navigator.device.capture.captureAudio(captureSuccess, captureError, {limit:2}); } //图片的捕获 function captureImageClik() { navigator.device.capture.captureImage(captureSuccess, captureError, {limit:2}); } //录像的获取 function captureVideoClik() { navigator.device.capture.captureVideo(captureSuccess, captureError, {limit:2}); } </script>

原文发布于微信公众号 - iOS开发笔记(roclel)

原文发表时间:2017-07-25

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

扫码关注云+社区

领取腾讯云代金券