武装少女在线观看高清完整版免费,丝袜+亚洲区,少妇被cao高潮呻吟声,午夜伦情电午夜伦情电影,日日躁夜夜躁狠狠躁

小程序模板網(wǎng)

微信小程序錄音與播放錄音

發(fā)布時間:2018-05-02 15:20 所屬欄目:小程序開發(fā)教程

小程序中提供了兩種錄音的API

  • 舊版錄音功能

首先啟動錄音,然后停止錄音即可拉到音頻的臨時地址

啟動錄音:


var that = this;
    wx.startRecord({
      success: function (res) {
       // 調(diào)用了停止錄音接口就會觸發(fā)這個函數(shù),res.tempFilePath為錄音文件臨時路徑
        var tempFilePath = res.tempFilePath
        that.setData({
          src: tempFilePath
        })
      },
      fail: function (res) {
        //錄音失敗的處理函數(shù)
      }
    })

停止錄音:


wx.stopRecord()

播放錄音:


wx.playVoice({
  filePath: src // src可以是錄音文件臨時路徑
})
  • 新版錄音

獲取全局唯一的錄音管理器,然后錄音都依賴他,而播放錄音則需要內(nèi)部 audio 上下文 innerAudioContext 對象。

獲取全局唯一的錄音管理器:


var that = this;
    this.recorderManager = wx.getRecorderManager();
    this.recorderManager.onError(function(){
      // 錄音失敗的回調(diào)處理
    });
    this.recorderManager.onStop(function(res){
      // 停止錄音之后,把錄取到的音頻放在res.tempFilePath
      that.setData({
        src: res.tempFilePath 
      })
      console.log(res.tempFilePath )
    });

開始錄音:


this.recorderManager.start({
      format: 'mp3'  // 如果錄制acc類型音頻則改成aac
});

結(jié)束錄音:


this.recorderManager.stop()

播放音頻:


this.innerAudioContext = wx.createInnerAudioContext();
    this.innerAudioContext.onError((res) => {
     // 播放音頻失敗的回調(diào)
    })
    this.innerAudioContext.src = this.data.src;  // 這里可以是錄音的臨時路徑
    this.innerAudioContext.play()


易優(yōu)小程序(企業(yè)版)+靈活api+前后代碼開源 碼云倉庫:starfork
本文地址:http://www.kknew.com.cn/wxmini/doc/course/24167.html 復(fù)制鏈接 如需定制請聯(lián)系易優(yōu)客服咨詢: 點擊咨詢
在線客服
易小優(yōu)
轉(zhuǎn)人工 ×