From 975d676e52f6d4512757a1a9634c3e585e3670c8 Mon Sep 17 00:00:00 2001 From: limin Date: Tue, 8 Dec 2020 16:50:06 +0800 Subject: [PATCH] feat: video --- pages/API/video/video.js | 58 ++++++++++++++++++++++++++++++++++++++ pages/API/video/video.json | 3 ++ pages/API/video/video.wxml | 58 ++++++++++++++++++++++++++++++++++++++ pages/API/video/video.wxss | 1 + 4 files changed, 120 insertions(+) create mode 100644 pages/API/video/video.js create mode 100644 pages/API/video/video.json create mode 100644 pages/API/video/video.wxml create mode 100644 pages/API/video/video.wxss diff --git a/pages/API/video/video.js b/pages/API/video/video.js new file mode 100644 index 0000000..b240f53 --- /dev/null +++ b/pages/API/video/video.js @@ -0,0 +1,58 @@ +// pages/API/video/video.js +const sourceType = [['camera'], ['album'], ['camera', 'album']] +const camera = [['front'], ['back'], ['front', 'back']] + +// eslint-disable-next-line +const duration = Array.apply(null, {length: 60}).map(function (n, i) { + return i + 1 +}) + +Page({ + onShareAppMessage() { + return { + title: '拍摄/选择视频', + path: 'packageAPI/pages/video/video' + } + }, + + data: { + sourceTypeIndex: 2, + sourceType: ['拍摄', '相册', '拍摄或相册'], + + cameraIndex: 2, + camera: ['前置', '后置', '前置或后置'], + + durationIndex: 59, + duration: duration.map(function (t) { return t + '秒' }), + + src: '' + }, + sourceTypeChange(e) { + this.setData({ + sourceTypeIndex: e.detail.value + }) + }, + cameraChange(e) { + this.setData({ + cameraIndex: e.detail.value + }) + }, + durationChange(e) { + this.setData({ + durationIndex: e.detail.value + }) + }, + chooseVideo() { + const that = this + wx.chooseVideo({ + sourceType: sourceType[this.data.sourceTypeIndex], + camera: camera[this.data.cameraIndex], + maxDuration: duration[this.data.durationIndex], + success(res) { + that.setData({ + src: res.tempFilePath + }) + } + }) + } +}) diff --git a/pages/API/video/video.json b/pages/API/video/video.json new file mode 100644 index 0000000..4ea4a95 --- /dev/null +++ b/pages/API/video/video.json @@ -0,0 +1,3 @@ +{ + "navigationBarTitleText": "拍摄/选择视频" +} diff --git a/pages/API/video/video.wxml b/pages/API/video/video.wxml new file mode 100644 index 0000000..f5e5a41 --- /dev/null +++ b/pages/API/video/video.wxml @@ -0,0 +1,58 @@ + + + + + +