From 0bb4df65f93f12a9bbcc03216ebfb54d7268b0f2 Mon Sep 17 00:00:00 2001 From: yinjiacheng Date: Tue, 10 Sep 2024 12:15:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0media=E7=A4=BA=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/API/get-image-info/get-image-info.uvue | 2 +- pages/API/get-video-info/get-video-info.uvue | 27 +++++++++++++++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/pages/API/get-image-info/get-image-info.uvue b/pages/API/get-image-info/get-image-info.uvue index 764a62d9..82f93e91 100644 --- a/pages/API/get-image-info/get-image-info.uvue +++ b/pages/API/get-image-info/get-image-info.uvue @@ -52,7 +52,7 @@ uni.getImageInfo({ src: res.tempFilePaths[0], success: (_res) => { - console.log("getImageInfo success", JSON.stringify(res)); + console.log("getImageInfo success", JSON.stringify(_res)); this.relativeImageInfo = `图片宽度: ${_res.width}\n图片高度: ${_res.height}\n图片路径: ${_res.path}\n图片方向: ${_res.orientation}\n图片格式: ${_res.type}`; }, fail: (err) => { diff --git a/pages/API/get-video-info/get-video-info.uvue b/pages/API/get-video-info/get-video-info.uvue index d692c702..431c9a73 100644 --- a/pages/API/get-video-info/get-video-info.uvue +++ b/pages/API/get-video-info/get-video-info.uvue @@ -3,6 +3,13 @@ + + + 获取本地相对路径视频信息 + + + {{relativeVideoInfo}} + 获取本地绝对路径视频信息 @@ -23,12 +30,30 @@ data() { return { title: "getVideoInfo", + relativeVideoPath: "/static/test-video/10second-demo.mp4", + relativeVideoInfo: "", absoluteVideoPath: "", absoluteVideoInfo: "", // 自动化测试 videoInfoForTest: null as UTSJSONObject | null } }, + onReady() { + uni.getVideoInfo({ + src: this.relativeVideoPath, + success: (res) => { + console.log("getVideoInfo success", JSON.stringify(res)); + this.relativeVideoInfo = `视频画面方向: ${res.orientation}\n视频格式: ${res.type}\n视频长度: ${res.duration}s\n视频大小: ${res.size}KB\n视频宽度: ${res.width}\n视频高度: ${res.height}\n视频帧率: ${res.fps}fps\n视频码率: ${res.bitrate}kbps`; + }, + fail: (err) => { + uni.showModal({ + title: "获取视频信息失败", + content: JSON.stringify(err), + showCancel: false + }); + } + }); + }, methods: { chooseVideo() { uni.chooseVideo({ @@ -38,7 +63,7 @@ uni.getVideoInfo({ src: res.tempFilePath, 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视频大小: ${_res.size}KB\n视频宽度: ${_res.width}\n视频高度: ${_res.height}\n视频帧率: ${_res.fps}fps\n视频码率: ${_res.bitrate}kbps`; }, fail: (err) => { -- GitLab