亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

微信小程序 Record API詳解及實例代碼

 更新時間:2016年09月30日 15:10:59   作者:順子_RTFSC  
這篇文章主要介紹了微信小程序 Record API詳解及實例代碼的相關(guān)資料,需要的朋友可以參考下

其實這個API也挺奇葩的,錄音結(jié)束后success不走,complete不走,fail也不走, 不知道是不是因為電腦測試的原因,只能等公測或者等他們完善。以后再測和補(bǔ)充吧?。。?!

主要屬性:

wx.startRecord(object)

手動調(diào)用wx.stopRecord()停止錄音

wxml

<!--用于記錄時間-->
<text>{{formatRecordTime}}</text>
<button type="primary" bindtap="listenerButtonStartRecord">開始錄音</button>
<button type="primary" bindtap="listenerButtonStopRecord">結(jié)束錄音</button>

js

var util = require('../../../utils/util.js')
var interval
Page({
 data:{
   //錄音顯示類型
  formatRecordTime: '00:00:00',
  //計數(shù)
  recordTime: 0,
 },

 onLoad:function(options){
  // 頁面初始化 options為頁面跳轉(zhuǎn)所帶來的參數(shù)
 },
 /**
  * 監(jiān)聽按鈕點擊開始錄音
  */
 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)
     }
   })
 },
 /**
  * 監(jiān)聽手動結(jié)束錄音
  */
 listenerButtonStopRecord: function() {
  wx.stopRecord();
  clearInterval(interval);
  this.setData({
    formatRecordTime: '00:00:00',
    recordTime: 0
  })
 },
 onReady:function(){
  // 頁面渲染完成
 },
 onShow:function(){
  // 頁面顯示
 },
 onHide:function(){
  // 頁面隱藏
 },
 /**
  * 當(dāng)界面關(guān)閉時停止定時器關(guān)閉錄音
  */
 onUnload:function(){
  // 頁面關(guān)閉
  wx.stopRecord()
  clearInterval(interval)
 }
})



感謝閱讀此文,希望能幫助到大家,謝謝大家對本站的支持!

相關(guān)文章

最新評論