微信小程序把玩(三十三)Record API
生活随笔
收集整理的這篇文章主要介紹了
微信小程序把玩(三十三)Record API
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
微信小程序把玩(三十三)Record API 原文:微信小程序把玩(三十三)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)} }) posted on 2017-02-26 15:41 NET未來之路 閱讀(...) 評論(...) 編輯 收藏轉載于:https://www.cnblogs.com/lonelyxmas/p/6444811.html
總結
以上是生活随笔為你收集整理的微信小程序把玩(三十三)Record API的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 开始使用gradle
- 下一篇: 获取iOS顶部状态栏和Navigatio