video.js
1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
var sourceType = [ ['camera'], ['album'], ['camera', 'album'] ]
var camera = [ ['front'], ['back'], ['front', 'back'] ]
var duration = Array.apply(null, {length: 60}).map(function (n, i) {
return i + 1
})
Page({
data: {
sourceTypeIndex: 2,
sourceType: ['拍摄', '相册', '拍摄或相册'],
cameraIndex: 2,
camera: ['前置', '后置', '前置或后置'],
durationIndex: 59,
duration: duration.map(function (t) { return t + '秒'}),
src: ''
},
sourceTypeChange: function (e) {
this.setData({
sourceTypeIndex: e.detail.value
})
},
cameraChange: function (e) {
this.setData({
cameraIndex: e.detail.value
})
},
durationChange: function (e) {
this.setData({
durationIndex: e.detail.value
})
},
chooseVideo: function () {
var that = this
wx.chooseVideo({
sourceType: sourceType[this.data.sourceTypeIndex],
camera: camera[this.data.cameraIndex],
maxDuration: duration[this.data.durationIndex],
success: function (res) {
that.setData({
src: res.tempFilePath
})
}
})
}
})