欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

微信小程序 Record API詳解及實(shí)例代碼

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

其實(shí)這個(gè)API也挺奇葩的,錄音結(jié)束后success不走,complete不走,fail也不走, 不知道是不是因?yàn)殡娔X測(cè)試的原因,只能等公測(cè)或者等他們完善。以后再測(cè)和補(bǔ)充吧?。。。?/p>

主要屬性:

wx.startRecord(object)

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

wxml

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

js

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

 onLoad:function(options){
  // 頁(yè)面初始化 options為頁(yè)面跳轉(zhuǎn)所帶來(lái)的參數(shù)
 },
 /**
  * 監(jiān)聽(tīng)按鈕點(diǎn)擊開(kāi)始錄音
  */
 listenerButtonStartRecord: function() {
   that = this;
   interval = setInterval(function() {
   that.data.recordTime += 1   
   that.setData({
     //格式化時(shí)間顯示
     formatRecordTime: util.formatTime(that.data.recordTime)
   })  
   }, 1000)
   wx.startRecord({
     success: function(res) {
       console.log(res)
       that.setData({
         //完成之后重新繪制
         formatRecordTime: util.formatTime(that.data.recordTime)
       })
     },
     /**
      * 完成清除定時(shí)器
      */
     complete: function() {
       clearInterval(interval)
     }
   })
 },
 /**
  * 監(jiān)聽(tīng)手動(dòng)結(jié)束錄音
  */
 listenerButtonStopRecord: function() {
  wx.stopRecord();
  clearInterval(interval);
  this.setData({
    formatRecordTime: '00:00:00',
    recordTime: 0
  })
 },
 onReady:function(){
  // 頁(yè)面渲染完成
 },
 onShow:function(){
  // 頁(yè)面顯示
 },
 onHide:function(){
  // 頁(yè)面隱藏
 },
 /**
  * 當(dāng)界面關(guān)閉時(shí)停止定時(shí)器關(guān)閉錄音
  */
 onUnload:function(){
  // 頁(yè)面關(guān)閉
  wx.stopRecord()
  clearInterval(interval)
 }
})



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

相關(guān)文章

最新評(píng)論