1. 程式人生 > >微信小程式-選擇視訊檔案及儲存到本地

微信小程式-選擇視訊檔案及儲存到本地

  bindButtonTap: function () {
    var that = this
    wx.chooseVideo({
      sourceType: ['album', 'camera'],
      maxDuration: 60,
      camera: ['front', 'back'],
      success: function (res) {
        wx.showToast({
          title: res.tempFilePath,
          icon: 'success',
          duration: 2000
        })


        that.setData({
          src: res.tempFilePath
        })


        wx.saveFile({
          tempFilePath: res.tempFilePath,
          success: function (res) {
            var savedFilePath = res.savedFilePath


            that.setData({
              address: res.tempFilePath,
            })


          }
        })


      }


      ,
      fail: function (res) {
        wx.showToast({
          title: '失敗',
          icon: 'success',
          duration: 2000


        })
      }


    })
  }