微信小程式-選擇視訊檔案及儲存到本地
阿新 • • 發佈:2019-01-25
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
})
}
})
}
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
})
}
})
}