title: Taro.getVideoInfo(option)

sidebar_label: getVideoInfo

获取视频详细信息

支持情况:getVideoInfo - 图1 getVideoInfo - 图2 getVideoInfo - 图3

参考文档

类型

  1. (option: Option) => Promise<SuccessCallbackResult>

参数

参数 类型
option Option

Option

参数 类型 必填 说明
src string 视频文件路径,可以是临时文件路径也可以是永久文件路径
success (result: SuccessCallbackResult) => void 接口调用成功的回调函数
fail (res: TaroGeneral.CallbackResult) => void 接口调用失败的回调函数
complete (res: TaroGeneral.CallbackResult) => void 接口调用结束的回调函数(调用成功、失败都会执行)

SuccessCallbackResult

参数 类型 说明
orientation keyof Orientation 画面方向
type string 视频格式
duration number 视频长度
size number 视频大小,单位 kB
height number 视频的长,单位 px
width number 视频的宽,单位 px
fps number 视频帧率
bitrate number 视频码率,单位 kbps

Orientation

参数 说明
up 默认
down 180 度旋转
left 逆时针旋转 90 度
right 顺时针旋转 90 度
up-mirrored 同 up,但水平翻转
down-mirrored 同 down,但水平翻转
left-mirrored 同 left,但垂直翻转
right-mirrored 同 right,但垂直翻转

示例代码

  1. Taro.downloadFile({
  2. url: 'https://mock.taro.org/mock_video.mp4',
  3. success(res) {
  4. Taro.getVideoInfo({
  5. src: res.tempFilePath,
  6. success (res) {
  7. console.log('获取文件地址成功')
  8. console.log(res)
  9. },
  10. fail (res) {
  11. console.log('获取文件地址失败')
  12. console.log(res)
  13. },
  14. complete (res) {
  15. console.log('获取文件地址')
  16. }
  17. })
  18. }
  19. })