原文:微信小程序把玩(三十三)Record API

其实这个API也挺奇葩的,录音结束后success不走,complete不走,fail也不走, 不知道是不是因为电脑测试的原因,只能等公测或者等他们完善。以后再测和补充吧!!!!

主要属性:

wx.startRecord(object)

手动调用wx.stopRecord()停止录音

wxml

<!--用于记录时间-->
<text>{{formatRecordTime}}</text>
<button type="primary" bindtap="listenerButtonStartRecord">开始录音</button>
<button type="primary" bindtap="listenerButtonStopRecord">结束录音</button>

js

var util = require('../../../utils/util.js')
var interval
Page({
data:{
//录音显示类型
formatRecordTime: '00:00:00',
//计数
recordTime: 0,
}, onLoad:function(options){
// 页面初始化 options为页面跳转所带来的参数
},
/**
* 监听按钮点击开始录音
*/
listenerButtonStartRecord: function() {
that = this;
interval = setInterval(function() {
that.data.recordTime += 1
that.setData({
//格式化时间显示
formatRecordTime: util.formatTime(that.data.recordTime)
})
}, 1000)
wx.startRecord({
success: function(res) {
console.log(res)
that.setData({
//完成之后重新绘制
formatRecordTime: util.formatTime(that.data.recordTime)
})
},
/**
* 完成清除定时器
*/
complete: function() {
clearInterval(interval)
}
})
},
/**
* 监听手动结束录音
*/
listenerButtonStopRecord: function() {
wx.stopRecord();
clearInterval(interval);
this.setData({
formatRecordTime: '00:00:00',
recordTime: 0
})
},
onReady:function(){
// 页面渲染完成
},
onShow:function(){
// 页面显示
},
onHide:function(){
// 页面隐藏
},
/**
* 当界面关闭时停止定时器关闭录音
*/
onUnload:function(){
// 页面关闭
wx.stopRecord()
clearInterval(interval)
}
})

微信小程序把玩(三十三)Record API的更多相关文章

  1. 微信小程序把玩(十三)progress组件

    原文:微信小程序把玩(十三)progress组件 进度条描述的是一种加载的状态,比如软件升级下载进度, 视频,图片下载进度- 主要属性: wxml <progress percent=" ...

  2. 微信小程序把玩(三)tabBar底部导航

    原文:微信小程序把玩(三)tabBar底部导航 tabBar相对而言用的还是比较多的,但是用起来并没有难,在app.json中配置下tabBar即可,注意tabBar至少需要两个最多五个Item选项 ...

  3. 微信小程序把玩(三十四)Audio API

    原文:微信小程序把玩(三十四)Audio API 没啥可值得太注意的地方 重要属性: 1. wx.getBackgroundAudioPlayerState(object) 获取播放状态 2.wx.p ...

  4. 微信小程序把玩(三十一)wx.uploadFile(object), wx.downloadFile(object) API

    原文:微信小程序把玩(三十一)wx.uploadFile(object), wx.downloadFile(object) API 反正我是没有测通这两个API!!!!不知道用的方式不对还是其他的!! ...

  5. 微信小程序把玩(三十九)navigation API

    原文:微信小程序把玩(三十九)navigation API 演示效果也看到了小程序也就提供这几个处理导航控制.值得注意的是只能同时导航五个页面 主要属性: 导航条一些方法 wx.setNavigati ...

  6. 微信小程序把玩(三十五)Video API

    原文:微信小程序把玩(三十五)Video API 电脑端不能测试拍摄功能只能测试选择视频功能,好像只支持mp4格式,值得注意的是成功之后返回的临时文件路径是个列表tempFilePaths而不是tem ...

  7. 微信小程序把玩(三十六)Storage API

    原文:微信小程序把玩(三十六)Storage API 其实这个存储在新建Demo的时候就已经用到了就是存储就是那个logs日志,数据存储主要分为同步和异步 异步存储方法: 存数据 wx.setStor ...

  8. 微信小程序把玩(三十七)location API

    原文:微信小程序把玩(三十七)location API location API也就分这里分两种wx.getLocation(object)获取当前位置和wx.openLocation(object) ...

  9. 微信小程序把玩(三十八)获取设备信息 API

    原文:微信小程序把玩(三十八)获取设备信息 API 获取设备信息这里分为四种, 主要属性: 网络信息wx.getNetWorkType, 系统信息wx.getSystemInfo, 重力感应数据wx. ...

随机推荐

  1. [Angular] @ViewChild and template #refs to get Element Ref

    We can use @ViewChild with component: @ViewChild(AuthMessageComponent) message: AuthMessageComponent ...

  2. gen_server笔记

    http://www.ask3.cn/a/jingcaibowen/tech/Erlang/2013/0614/42043.html gen_server是erlang的OTP框架中最常用的“行为模式 ...

  3. 简单易用的动画animations

    _tableView_selc.frame=CGRectMake(20, , 20,20); [UIView animateWithDuration:0.3f animations:^{ _table ...

  4. tolua#是Unity静态绑定lua的一个解决方案

    tolua#代码简要分析 2017-04-16 23:02 by 风恋残雪, 98 阅读, 1 评论, 收藏, 编辑 简介 tolua#是Unity静态绑定lua的一个解决方案,它通过C#提供的反射信 ...

  5. 使用HAXM为QEMU for Windows加速

    QEMU是一款支持多种CPU的虚拟化软件,本身基于软件虚拟化,效率不高,在linux下可以基于KVM加速,据说可以获得接近物理机的性能.网上有很多关于QEMU+KVM的使用说明,但是KVM仅用于lin ...

  6. jQuery整体架构

    (function(global, factory) { factory(global); }(typeof window !== "undefined" ? window : t ...

  7. 嵌套函数中的this

    function countDown(){ var self = this; var doWork = function(){ console.log(this);//window console.l ...

  8. Windows 下 MySQL-python 的安装

    1. 标准方式 进入终端: > pip install MySQL-python 第一次安装(windows 下安装),可能会出错:缺少 vs 编译器,提示点击如下网站 Download Mic ...

  9. windows 路径

    windows下的路径分隔符是\,而不是/ hosts文件的位置:C:\Windows\system32\drivers\etc 安卓(Android)用户:Android手机hosts文件路径:/s ...

  10. hibernate validator 专题

    JSR-303 原生支持的限制有如下几种 : 限制 说明 @Null 限制只能为 null @NotNull 限制必须不为 null @AssertFalse 限制必须为 false @AssertT ...