【2025年1月2日】关于腾讯云小程序平台更名为腾讯云超级应用服务的公告
控制台更新动态
Android SDK 更新动态
iOS SDK 更新动态
Flutter 更新动态
IDE 更新动态
基础库更新动态
属性 | 类型 | 默认值 | 必填 | 说明 |
filePath | string | - | 是 | 视频文件路径,可以是临时文件路径也可以是永久文件路径 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
wx.saveVideoToPhotosAlbum({filePath: 'wxfile://xxx',success(res) {console.log(res.errMsg)},})
属性 | 类型 | 默认值 | 必填 | 说明 |
sourceType | Array.<string> | ['album', 'camera'] | 否 | 视频选择来源 |
compressed | boolean | true | 否 | 是否压缩所选择的视频文件 |
maxDuration | number | 60 | 否 | 拍摄视频,最长拍摄时间,单位:秒 |
camera | string | 'back' | 否 | 默认拉起的是前置或者后置摄像头。部分 Android 手机下由于系统 ROM 不支持无法生效 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
值 | 说明 |
album | 从相册选择视频 |
camera | 使用相机拍摄视频 |
值 | 说明 |
back | 默认拉起后置摄像头 |
front | 默认拉起前置摄像头 |
属性 | 类型 | 说明 |
tempFilePath | string | 选定视频的临时文件路径 |
duration | number | 选定视频的时间长度 |
size | number | 选定视频的数据量大小,单位 B |
height | number | 返回选定视频的高度 |
width | number | 返回选定视频的宽度 |
wx.chooseVideo({sourceType: ['album', 'camera'],maxDuration: 60,camera: 'back',success(res) {console.log(res.tempFilePath)},})
quality 进行压缩。当需要更精细的控制时,可指定 bitrate、fps和 resolution,当 quality 传入时,这三个参数将被忽略。属性 | 类型 | 必填 | 说明 |
src | string | 是 | 视频文件路径,可以是临时文件路径也可以是永久文件路径 |
quality | string | 是 | 压缩质量,合法值为: low:低 medium:中 high:高 |
bitrate | number | 是 | 码率,单位 kbps |
fps | number | 是 | 帧率 |
resolution | number | 是 | 相对于原视频的分辨率比例,取值范围(0, 1] |
success | function | 否 | 接口调用成功的回调函数 |
fail | function | 否 | 接口调用失败的回调函数 |
complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
属性 | 类型 | 说明 |
tempFilePath | string | 压缩后的临时文件地址 |
size | string | 压缩后的大小,单位 KB |
属性 | 类型 | 默认值 | 必填 | 说明 |
count | number | 15 | 否 | 最多可以选择的文件个数,最多可支持15个文件 |
mediaType | Array.<string> | ['image','video'] | 否 | 文件类型,合法值为: image:只能拍摄图片或从相册选择图片 video:只能拍摄或从相册选择视频 注意: iOS 可选择任何系统照片 App 支持的图片格式。通常包括 JPG, PNG, HEIC (取决于设备型号和 iOS 版本), 以及 GIF 等。 |
sourceType | Array.<string> | ['album', 'camera'] | 否 | 图片和视频选择的来源,合法值为: album:从相册选择 camera:使用相机拍摄 |
maxDuration | number | 10 | 否 | 拍摄视频最长拍摄时间,单位秒。时间范围为 3s 至 60s。不限制相册。 |
sizeType | Array.<string> | ['original', 'compressed'] | 否 | 仅对 mediaType 为 image 时有效,是否压缩所选文件 |
camera | string | 'back' | 否 | 仅在 sourceType 为 camera 时生效,使用前置或后置摄像头,合法值为: back:使用后置摄像头 front:使用前置摄像头 |
success | function | - | 否 | 接口调用成功的回调函数 |
fail | function | - | 否 | 接口调用失败的回调函数 |
complete | function | - | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
属性 | 类型 | 说明 |
tempFiles | Array.<Object> | 本地临时文件列表 |
type | string | 文件类型,有效值有 image 、video |
结构属性 | 类型 | 说明 |
tempFilePath | string | 本地临时文件路径(本地目录) |
size | number | 本地临时文件大小,单位 B |
duration | number | 视频的时间长度 |
height | number | 视频的高度 |
width | number | 视频的宽度 |
thumbTempFilePath | string | 视频缩略图临时文件路径 |
fileType | string | 文件类型,合法值有: image:图片 video:视频 |
wx.chooseMedia({count: 9,mediaType: ['image','video'],sourceType: ['album', 'camera'],maxDuration: 30,camera: 'back',success(res) {console.log(res.tempFiles.tempFilePath)console.log(res.tempFiles.size)}})
<view class="section tc"><videoid="myVideo"src="http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400"enable-danmudanmu-btncontrols></video><view class="btn-area"><input bindblur="bindInputBlur" /><button bindtap="bindSendDanmu">发送弹幕</button></view></view>
function getRandomColor() {const rgb = []for (let i = 0; i < 3; ++i) {let color = Math.floor(Math.random() * 256).toString(16)color = color.length == 1 ? '0' + color : colorrgb.push(color)}return '#' + rgb.join('')}Page({onReady(res) {this.videoContext = wx.createVideoContext('myVideo')},inputValue: '',bindInputBlur(e) {this.inputValue = e.detail.value},bindSendDanmu() {this.videoContext.sendDanmu({text: this.inputValue,color: getRandomColor(),})},})
属性 | 类型 | 默认值 | 必填 | 说明 |
direction | number | - | 否 | 设置全屏时视频的方向,不指定则根据宽高比自动判断 |
值 | 说明 |
0 | 正常竖向 |
90 | 屏幕逆时针 90 度 |
-90 | 屏幕顺时针 90 度 |
属性 | 类型 | 默认值 | 必填 | 说明 |
text | string | - | 是 | 弹幕文字 |
color | string | - | 否 | 弹幕颜色 |
属性 | 类型 | 说明 |
videoPlayerType | string | 当前播放器类型,合法值:SystemPlayer / VodPlayer |
文档反馈