feat: video
parent
b0a2eb5788
commit
975d676e52
|
@ -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
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
|
@ -0,0 +1,3 @@
|
||||||
|
{
|
||||||
|
"navigationBarTitleText": "拍摄/选择视频"
|
||||||
|
}
|
|
@ -0,0 +1,58 @@
|
||||||
|
<!--pages/API/video/video.wxml-->
|
||||||
|
<import src="../../common/head.wxml" />
|
||||||
|
<import src="../../common/foot.wxml" />
|
||||||
|
|
||||||
|
<view class="container">
|
||||||
|
<template is="head" data="{{title: 'chooseVideo'}}"/>
|
||||||
|
|
||||||
|
<view class="page-body">
|
||||||
|
<view class="page-section">
|
||||||
|
<view class="weui-cells weui-cells_after-title">
|
||||||
|
<view class="weui-cell weui-cell_input">
|
||||||
|
<view class="weui-cell__hd">
|
||||||
|
<view class="weui-label">视频来源</view>
|
||||||
|
</view>
|
||||||
|
<view class="weui-cell__bd">
|
||||||
|
<picker range="{{sourceType}}" bindchange="sourceTypeChange" value="{{sourceTypeIndex}}">
|
||||||
|
<view class="weui-input">{{sourceType[sourceTypeIndex]}}</view>
|
||||||
|
</picker>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="weui-cell weui-cell_input">
|
||||||
|
<view class="weui-cell__hd">
|
||||||
|
<view class="weui-label">摄像头</view>
|
||||||
|
</view>
|
||||||
|
<view class="weui-cell__bd">
|
||||||
|
<picker range="{{camera}}" bindchange="cameraChange" value="{{cameraIndex}}">
|
||||||
|
<view class="weui-input">{{camera[cameraIndex]}}</view>
|
||||||
|
</picker>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
<view class="weui-cell weui-cell_input">
|
||||||
|
<view class="weui-cell__hd">
|
||||||
|
<view class="weui-label">拍摄长度</view>
|
||||||
|
</view>
|
||||||
|
<view class="weui-cell__bd">
|
||||||
|
<picker range="{{duration}}" bindchange="durationChange" value="{{durationIndex}}">
|
||||||
|
<view class="weui-input">{{duration[durationIndex]}}</view>
|
||||||
|
</picker>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
||||||
|
<view class="page-body-info">
|
||||||
|
<block wx:if="{{src === ''}}">
|
||||||
|
<view class="image-plus image-plus-nb" bindtap="chooseVideo">
|
||||||
|
<view class="image-plus-horizontal"></view>
|
||||||
|
<view class="image-plus-vertical"></view>
|
||||||
|
</view>
|
||||||
|
<view class="image-plus-text">添加视频</view>
|
||||||
|
</block>
|
||||||
|
<block wx:if="{{src != ''}}">
|
||||||
|
<video src="{{src}}" class="video"></video>
|
||||||
|
</block>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
</view>
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
/* pages/API/video/video.wxss */
|
Loading…
Reference in New Issue