Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
e0ab9857
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6013
Star
91
Fork
164
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
e0ab9857
编写于
5月 14, 2024
作者:
DCloud-yinjiacheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
更新media示例
上级
9eb17436
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
39 addition
and
33 deletion
+39
-33
pages/API/choose-video/choose-video.uvue
pages/API/choose-video/choose-video.uvue
+5
-3
pages/API/compress-image/compress-image.uvue
pages/API/compress-image/compress-image.uvue
+19
-8
pages/API/compress-video/compress-video.uvue
pages/API/compress-video/compress-video.uvue
+11
-18
pages/API/get-video-info/get-video-info.uvue
pages/API/get-video-info/get-video-info.uvue
+2
-2
pages/API/save-video-to-photos-album/save-video-to-photos-album.uvue
...ave-video-to-photos-album/save-video-to-photos-album.uvue
+2
-2
未找到文件。
pages/API/choose-video/choose-video.uvue
浏览文件 @
e0ab9857
...
@@ -4,13 +4,15 @@
...
@@ -4,13 +4,15 @@
<!-- #endif -->
<!-- #endif -->
<page-head :title="title"></page-head>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap">
<view class="uni-padding-wrap">
<video class="video" :src="src"></video>
<video class="video" :src="src"
:controls="true"
></video>
<view class="uni-btn-v">
<view class="uni-btn-v">
<button type="primary" @click="chooseVideo">选取视频</button>
<button type="primary" @click="chooseVideo">选取视频</button>
</view>
</view>
<enum-data title="视频来源" :items="sourceTypeItemTypes" @change="onSourceTypeChange"></enum-data>
<enum-data title="视频来源" :items="sourceTypeItemTypes" @change="onSourceTypeChange"></enum-data>
<enum-data title="摄像头" :items="cameraItemTypes" @change="onCameraChange"></enum-data>
<enum-data title="摄像头" :items="cameraItemTypes" @change="onCameraChange"></enum-data>
<input-data title="最长拍摄时间,单位秒" defaultValue="60" type="number" @confirm="onMaxDurationConfirm"></input-data>
</view>
<input-data title="最长拍摄时间,单位秒" defaultValue="60" type="number" @confirm="onMaxDurationConfirm"></input-data>
<view class="uni-padding-wrap">
<boolean-data title="是否压缩" :defaultValue="true" @change="onCompressedChange"></boolean-data>
<boolean-data title="是否压缩" :defaultValue="true" @change="onCompressedChange"></boolean-data>
</view>
</view>
<!-- #ifdef APP -->
<!-- #ifdef APP -->
...
@@ -19,7 +21,7 @@
...
@@ -19,7 +21,7 @@
</template>
</template>
<script>
<script>
import { ItemType } from '@/components/enum-data/enum-data'
import { ItemType } from '@/components/enum-data/enum-data'
;
export default {
export default {
data() {
data() {
return {
return {
...
...
pages/API/compress-image/compress-image.uvue
浏览文件 @
e0ab9857
...
@@ -25,8 +25,8 @@
...
@@ -25,8 +25,8 @@
</view>
</view>
<input-data defaultValue="80" title="压缩质量,范围0~100,数值越小,质量越低,压缩率越高(仅对jpg有效)" type="number"
<input-data defaultValue="80" title="压缩质量,范围0~100,数值越小,质量越低,压缩率越高(仅对jpg有效)" type="number"
@confirm="onQualityConfirm"></input-data>
@confirm="onQualityConfirm"></input-data>
<input-data title="压缩后图片的宽度,单位px" type="
number
" @confirm="onCompressedWidthConfirm"></input-data>
<input-data title="压缩后图片的宽度,单位px" type="
string
" @confirm="onCompressedWidthConfirm"></input-data>
<input-data title="压缩后图片的高度,单位px" type="
number
" @confirm="onCompressedHeightConfirm"></input-data>
<input-data title="压缩后图片的高度,单位px" type="
string
" @confirm="onCompressedHeightConfirm"></input-data>
<input-data defaultValue="auto" title="压缩后图片的宽度,支持px、%、auto" type="string" @confirm="onWidthConfirm"></input-data>
<input-data defaultValue="auto" title="压缩后图片的宽度,支持px、%、auto" type="string" @confirm="onWidthConfirm"></input-data>
<input-data defaultValue="auto" title="压缩后图片的高度,支持px、%、auto" type="string" @confirm="onHeightConfirm"></input-data>
<input-data defaultValue="auto" title="压缩后图片的高度,支持px、%、auto" type="string" @confirm="onHeightConfirm"></input-data>
<input-data defaultValue="0" title="旋转度数,范围0~360" type="number" @confirm="onRotateConfirm"></input-data>
<input-data defaultValue="0" title="旋转度数,范围0~360" type="number" @confirm="onRotateConfirm"></input-data>
...
@@ -36,6 +36,9 @@
...
@@ -36,6 +36,9 @@
</template>
</template>
<script>
<script>
// #ifdef APP-ANDROID
import FileInputStream from 'java.io.FileInputStream';
// #endif
export default {
export default {
data() {
data() {
return {
return {
...
@@ -82,7 +85,11 @@
...
@@ -82,7 +85,11 @@
uni.getImageInfo({
uni.getImageInfo({
src: res.tempFilePath,
src: res.tempFilePath,
success: (_res) => {
success: (_res) => {
this.afterCompressImageInfo = `图片宽度: ${_res.width}, 图片高度: ${_res.height}`;
this.afterCompressImageInfo = `图片宽度: ${_res.width}\n图片高度: ${_res.height}\n`;
// #ifdef APP-ANDROID
const size = new FileInputStream(res.tempFilePath.substring("file://".length)).available() / 1024;
this.afterCompressImageInfo = this.afterCompressImageInfo.concat(`图片大小: ${size}KB`);
// #endif
}
}
});
});
},
},
...
@@ -108,7 +115,11 @@
...
@@ -108,7 +115,11 @@
uni.getImageInfo({
uni.getImageInfo({
src: res.tempFilePaths[0],
src: res.tempFilePaths[0],
success: (_res) => {
success: (_res) => {
this.beforeCompressImageInfo = `图片宽度: ${_res.width}, 图片高度: ${_res.height}`;
this.beforeCompressImageInfo = `图片宽度: ${_res.width}\n图片高度: ${_res.height}\n`;
// #ifdef APP-ANDROID
const size = new FileInputStream(res.tempFilePaths[0].substring("file://".length)).available() / 1024;
this.beforeCompressImageInfo = this.beforeCompressImageInfo.concat(`图片大小: ${size}KB`);
// #endif
}
}
});
});
}
}
...
@@ -117,11 +128,11 @@
...
@@ -117,11 +128,11 @@
onQualityConfirm(value : number) {
onQualityConfirm(value : number) {
this.quality = value;
this.quality = value;
},
},
onCompressedWidthConfirm(value :
number
) {
onCompressedWidthConfirm(value :
string
) {
this.compressedWidth =
value
;
this.compressedWidth =
parseInt(value)
;
},
},
onCompressedHeightConfirm(value :
number
) {
onCompressedHeightConfirm(value :
string
) {
this.compressedHeight =
value
;
this.compressedHeight =
parseInt(value)
;
},
},
onWidthConfirm(value : string) {
onWidthConfirm(value : string) {
this.width = value;
this.width = value;
...
...
pages/API/compress-video/compress-video.uvue
浏览文件 @
e0ab9857
...
@@ -4,11 +4,12 @@
...
@@ -4,11 +4,12 @@
<!-- #endif -->
<!-- #endif -->
<page-head :title="title"></page-head>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap">
<view class="uni-padding-wrap">
<video class="video" :src="
src
"></video>
<video class="video" :src="
beforeCompressPath" :controls="true
"></video>
<view class="uni-title">
<view class="uni-title">
<text class="uni-subtitle-text">压缩前视频信息</text>
<text class="uni-subtitle-text">压缩前视频信息</text>
</view>
</view>
<text>{{beforeCompressVideoInfo}}</text>
<text>{{beforeCompressVideoInfo}}</text>
<video class="video" :src="afterCompressPath" :controls="true"></video>
<view class="uni-title">
<view class="uni-title">
<text class="uni-subtitle-text">压缩后视频信息</text>
<text class="uni-subtitle-text">压缩后视频信息</text>
</view>
</view>
...
@@ -19,11 +20,8 @@
...
@@ -19,11 +20,8 @@
<view class="uni-btn-v">
<view class="uni-btn-v">
<button type="primary" @click="compressVideo">压缩视频</button>
<button type="primary" @click="compressVideo">压缩视频</button>
</view>
</view>
<enum-data title="压缩质量" :items="qualityItemTypes" @change="onQualityChange"></enum-data>
</view>
</view>
<input-data :defaultValue="null" title="压缩质量,low(低) medium(中) high(高)" type="string"
@confirm="onQualityConfirm"></input-data>
<!-- <input-data :defaultValue="null" title="码率,单位kbps" type="number" @confirm="onBitrateConfirm"></input-data> -->
<!-- <input-data :defaultValue="null" title="帧率" type="number" @confirm="onFpsConfirm"></input-data> -->
<input-data :defaultValue="null" title="相对于原视频的分辨率比例,取值范围(0, 1]" type="string"
<input-data :defaultValue="null" title="相对于原视频的分辨率比例,取值范围(0, 1]" type="string"
@confirm="onResolutionConfirm"></input-data>
@confirm="onResolutionConfirm"></input-data>
<!-- #ifdef APP -->
<!-- #ifdef APP -->
...
@@ -32,11 +30,11 @@
...
@@ -32,11 +30,11 @@
</template>
</template>
<script>
<script>
import { ItemType } from '@/components/enum-data/enum-data';
export default {
export default {
data() {
data() {
return {
return {
title: "compressVideo",
title: "compressVideo",
src: "",
beforeCompressVideoInfo: "",
beforeCompressVideoInfo: "",
afterCompressVideoInfo: "",
afterCompressVideoInfo: "",
beforeCompressPath: "",
beforeCompressPath: "",
...
@@ -45,6 +43,8 @@
...
@@ -45,6 +43,8 @@
bitrate: null as number | null,
bitrate: null as number | null,
fps: null as number | null,
fps: null as number | null,
resolution: null as number | null,
resolution: null as number | null,
qualityItemTypes: [{ "value": 0, "name": "low(低)" }, { "value": 1, "name": "medium(中)" }, { "value": 2, "name": "high(高)" }] as ItemType[],
qualityItems: ["low", "medium", "high"]
}
}
},
},
methods: {
methods: {
...
@@ -65,7 +65,7 @@
...
@@ -65,7 +65,7 @@
resolution: this.resolution,
resolution: this.resolution,
success: (res) => {
success: (res) => {
console.log("compressVideo success", JSON.stringify(res));
console.log("compressVideo success", JSON.stringify(res));
this.
src
= res.tempFilePath;
this.
afterCompressPath
= res.tempFilePath;
uni.showToast({
uni.showToast({
title: "压缩成功",
title: "压缩成功",
icon: null
icon: null
...
@@ -73,7 +73,7 @@
...
@@ -73,7 +73,7 @@
uni.getVideoInfo({
uni.getVideoInfo({
src: res.tempFilePath,
src: res.tempFilePath,
success: (_res) => {
success: (_res) => {
this.afterCompressVideoInfo = `视频画面方向: ${_res.orientation}\n视频格式: ${_res.type}\n视频长度: ${_res.duration}s\n视频大小: ${Math.ceil(_res.size / 1024)}
k
B\n视频宽度: ${_res.width}\n视频高度: ${_res.height}\n视频帧率: ${_res.fps}fps\n视频码率: ${_res.bitrate}kbps`;
this.afterCompressVideoInfo = `视频画面方向: ${_res.orientation}\n视频格式: ${_res.type}\n视频长度: ${_res.duration}s\n视频大小: ${Math.ceil(_res.size / 1024)}
K
B\n视频宽度: ${_res.width}\n视频高度: ${_res.height}\n视频帧率: ${_res.fps}fps\n视频码率: ${_res.bitrate}kbps`;
}
}
});
});
},
},
...
@@ -95,24 +95,17 @@
...
@@ -95,24 +95,17 @@
compressed: false,
compressed: false,
success: (res) => {
success: (res) => {
this.beforeCompressPath = res.tempFilePath;
this.beforeCompressPath = res.tempFilePath;
this.src = res.tempFilePath;
uni.getVideoInfo({
uni.getVideoInfo({
src: res.tempFilePath,
src: res.tempFilePath,
success: (_res) => {
success: (_res) => {
this.beforeCompressVideoInfo = `视频画面方向: ${_res.orientation}\n视频格式: ${_res.type}\n视频长度: ${_res.duration}s\n视频大小: ${Math.ceil(_res.size / 1024)}
k
B\n视频宽度: ${_res.width}\n视频高度: ${_res.height}\n视频帧率: ${_res.fps}fps\n视频码率: ${_res.bitrate}kbps`;
this.beforeCompressVideoInfo = `视频画面方向: ${_res.orientation}\n视频格式: ${_res.type}\n视频长度: ${_res.duration}s\n视频大小: ${Math.ceil(_res.size / 1024)}
K
B\n视频宽度: ${_res.width}\n视频高度: ${_res.height}\n视频帧率: ${_res.fps}fps\n视频码率: ${_res.bitrate}kbps`;
}
}
});
});
}
}
});
});
},
},
onQualityConfirm(value : string) {
onQualityChange(value : number) {
this.quality = value;
this.quality = this.qualityItems[value];
},
onBitrateConfirm(value : number) {
this.bitrate = value;
},
onFpsConfirm(value : number) {
this.fps = value;
},
},
onResolutionConfirm(value : string) {
onResolutionConfirm(value : string) {
this.resolution = parseFloat(value);
this.resolution = parseFloat(value);
...
...
pages/API/get-video-info/get-video-info.uvue
浏览文件 @
e0ab9857
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
<view class="uni-title">
<view class="uni-title">
<text class="uni-subtitle-text">获取本地绝对路径视频信息</text>
<text class="uni-subtitle-text">获取本地绝对路径视频信息</text>
</view>
</view>
<video class="video" :src="absoluteVideoPath"></video>
<video class="video" :src="absoluteVideoPath"
:controls="true"
></video>
<text class="margin-top-10">{{absoluteVideoInfo}}</text>
<text class="margin-top-10">{{absoluteVideoInfo}}</text>
<view class="uni-btn-v">
<view class="uni-btn-v">
<button type="primary" @click="chooseVideo">拍摄视频或从相册中选择视频</button>
<button type="primary" @click="chooseVideo">拍摄视频或从相册中选择视频</button>
...
@@ -37,7 +37,7 @@
...
@@ -37,7 +37,7 @@
src: res.tempFilePath,
src: res.tempFilePath,
success: (_res) => {
success: (_res) => {
console.log("getVideoInfo success", JSON.stringify(res));
console.log("getVideoInfo success", JSON.stringify(res));
this.absoluteVideoInfo = `视频画面方向: ${_res.orientation}\n视频格式: ${_res.type}\n视频长度: ${_res.duration}s\n视频大小: ${Math.ceil(_res.size / 1024)}
k
B\n视频宽度: ${_res.width}\n视频高度: ${_res.height}\n视频帧率: ${_res.fps}fps\n视频码率: ${_res.bitrate}kbps`;
this.absoluteVideoInfo = `视频画面方向: ${_res.orientation}\n视频格式: ${_res.type}\n视频长度: ${_res.duration}s\n视频大小: ${Math.ceil(_res.size / 1024)}
K
B\n视频宽度: ${_res.width}\n视频高度: ${_res.height}\n视频帧率: ${_res.fps}fps\n视频码率: ${_res.bitrate}kbps`;
},
},
fail: (err) => {
fail: (err) => {
uni.showModal({
uni.showModal({
...
...
pages/API/save-video-to-photos-album/save-video-to-photos-album.uvue
浏览文件 @
e0ab9857
...
@@ -4,7 +4,7 @@
...
@@ -4,7 +4,7 @@
<!-- #endif -->
<!-- #endif -->
<page-head :title="title"></page-head>
<page-head :title="title"></page-head>
<view class="uni-padding-wrap">
<view class="uni-padding-wrap">
<video class="video" :src="src"></video>
<video class="video" :src="src"
:controls="true"
></video>
<button type="primary" class="margin-top-10" @click="saveVideo">将视频保存到手机相册</button>
<button type="primary" class="margin-top-10" @click="saveVideo">将视频保存到手机相册</button>
</view>
</view>
<!-- #ifdef APP -->
<!-- #ifdef APP -->
...
@@ -47,7 +47,7 @@
...
@@ -47,7 +47,7 @@
title: '视频下载中'
title: '视频下载中'
});
});
uni.downloadFile({
uni.downloadFile({
url: 'https://qiniu-web-assets.dcloud.net.cn/
video/sample/2minute-demo
.mp4',
url: 'https://qiniu-web-assets.dcloud.net.cn/
uni-app-x/static/video/swiper-vertical-video/uts
.mp4',
success: (res) => {
success: (res) => {
console.log("download video success", res.tempFilePath);
console.log("download video success", res.tempFilePath);
this.src = res.tempFilePath;
this.src = res.tempFilePath;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录