init
This commit is contained in:
11
xhs-mini-demos/api-case/video/video.css
Normal file
11
xhs-mini-demos/api-case/video/video.css
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
.page-body-info {
|
||||
display: flex;
|
||||
margin-top: 20px;
|
||||
padding: 0;
|
||||
height: 330px;
|
||||
border-top: 1px solid var(--weui-FG-3);
|
||||
border-bottom: 1px solid var(--weui-FG-3);
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
57
xhs-mini-demos/api-case/video/video.js
Normal file
57
xhs-mini-demos/api-case/video/video.js
Normal file
@@ -0,0 +1,57 @@
|
||||
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(t => `${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;
|
||||
xhs.chooseVideo?.({
|
||||
sourceType: sourceType[this.data.sourceTypeIndex],
|
||||
camera: camera[this.data.cameraIndex],
|
||||
maxDuration: duration[this.data.durationIndex],
|
||||
success(res) {
|
||||
that.setData({
|
||||
src: res.tempFilePath,
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
});
|
||||
7
xhs-mini-demos/api-case/video/video.json
Normal file
7
xhs-mini-demos/api-case/video/video.json
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"navigationBarTitleText": "拍摄/选择视频",
|
||||
"usingComponents": {
|
||||
"showbox": "../../common/component/showbox/index",
|
||||
"box": "../../common/component/container/index"
|
||||
}
|
||||
}
|
||||
49
xhs-mini-demos/api-case/video/video.xhsml
Normal file
49
xhs-mini-demos/api-case/video/video.xhsml
Normal file
@@ -0,0 +1,49 @@
|
||||
<view class="container">
|
||||
<view class="page-body">
|
||||
<showbox title="默认">
|
||||
<box>
|
||||
<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">
|
||||
<view xhs:if="{{src === ''}}" bindtap="chooseVideo">添加视频</view>
|
||||
<block xhs:if="{{src != ''}}">
|
||||
<video src="{{src}}" class="video"></video>
|
||||
</block>
|
||||
</view>
|
||||
</view>
|
||||
</box>
|
||||
</showbox>
|
||||
</view>
|
||||
</view>
|
||||
Reference in New Issue
Block a user