Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qianlong66
uni-app
提交
4553386d
U
uni-app
项目概览
qianlong66
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
4553386d
编写于
4月 16, 2021
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(h5): getVideoInfo
上级
01c1d580
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
128 addition
and
1 deletion
+128
-1
packages/uni-api/src/index.ts
packages/uni-api/src/index.ts
+1
-0
packages/uni-api/src/protocols/media/getVideoInfo.ts
packages/uni-api/src/protocols/media/getVideoInfo.ts
+19
-0
packages/uni-h5/dist/uni-h5.esm.js
packages/uni-h5/dist/uni-h5.esm.js
+50
-1
packages/uni-h5/src/service/api/index.ts
packages/uni-h5/src/service/api/index.ts
+1
-0
packages/uni-h5/src/service/api/media/getVideoInfo.ts
packages/uni-h5/src/service/api/media/getVideoInfo.ts
+57
-0
未找到文件。
packages/uni-api/src/index.ts
浏览文件 @
4553386d
...
@@ -29,6 +29,7 @@ export * from './protocols/media/chooseImage'
...
@@ -29,6 +29,7 @@ export * from './protocols/media/chooseImage'
export
*
from
'
./protocols/media/chooseVideo
'
export
*
from
'
./protocols/media/chooseVideo
'
export
*
from
'
./protocols/media/chooseFile
'
export
*
from
'
./protocols/media/chooseFile
'
export
*
from
'
./protocols/media/getImageInfo
'
export
*
from
'
./protocols/media/getImageInfo
'
export
*
from
'
./protocols/media/getVideoInfo
'
export
*
from
'
./protocols/network/request
'
export
*
from
'
./protocols/network/request
'
export
*
from
'
./protocols/network/downloadFile
'
export
*
from
'
./protocols/network/downloadFile
'
...
...
packages/uni-api/src/protocols/media/getVideoInfo.ts
0 → 100644
浏览文件 @
4553386d
import
{
getRealPath
}
from
'
@dcloudio/uni-platform
'
export
const
API_GET_VIDEO_INFO
=
'
getVideoInfo
'
export
type
API_TYPE_GET_VIDEO_INFO
=
typeof
uni
.
getVideoInfo
export
const
GetVideoInfoOptions
:
ApiOptions
<
API_TYPE_GET_VIDEO_INFO
>
=
{
formatArgs
:
{
src
(
src
,
params
)
{
params
.
src
=
getRealPath
(
src
)
},
},
}
export
const
GetVideoInfoProtocol
:
ApiProtocol
<
API_TYPE_GET_VIDEO_INFO
>
=
{
src
:
{
type
:
String
,
required
:
true
,
},
}
packages/uni-h5/dist/uni-h5.esm.js
浏览文件 @
4553386d
...
@@ -4635,6 +4635,20 @@ const GetImageInfoProtocol = {
...
@@ -4635,6 +4635,20 @@ const GetImageInfoProtocol = {
required
:
true
required
:
true
}
}
};
};
const
API_GET_VIDEO_INFO
=
"
getVideoInfo
"
;
const
GetVideoInfoOptions
=
{
formatArgs
:
{
src
(
src
,
params
)
{
params
.
src
=
getRealPath
(
src
);
}
}
};
const
GetVideoInfoProtocol
=
{
src
:
{
type
:
String
,
required
:
true
}
};
const
API_REQUEST
=
"
request
"
;
const
API_REQUEST
=
"
request
"
;
const
dataType
=
{
const
dataType
=
{
JSON
:
"
json
"
JSON
:
"
json
"
...
@@ -11027,6 +11041,40 @@ const getImageInfo = defineAsyncApi(API_GET_IMAGE_INFO, ({src}, {resolve, reject
...
@@ -11027,6 +11041,40 @@ const getImageInfo = defineAsyncApi(API_GET_IMAGE_INFO, ({src}, {resolve, reject
};
};
img
.
src
=
src
;
img
.
src
=
src
;
},
GetImageInfoProtocol
,
GetImageInfoOptions
);
},
GetImageInfoProtocol
,
GetImageInfoOptions
);
const
getVideoInfo
=
defineAsyncApi
(
API_GET_VIDEO_INFO
,
({
src
},
{
resolve
,
reject
})
=>
{
urlToFile
(
src
,
true
).
then
((
file
)
=>
{
return
file
;
}).
catch
(()
=>
{
return
null
;
}).
then
((
file
)
=>
{
const
video
=
document
.
createElement
(
"
video
"
);
if
(
video
.
onloadedmetadata
!==
void
0
)
{
const
handle
=
setTimeout
(()
=>
{
video
.
onloadedmetadata
=
null
;
video
.
onerror
=
null
;
reject
();
},
src
.
startsWith
(
"
data:
"
)
||
src
.
startsWith
(
"
blob:
"
)
?
300
:
3
e3
);
video
.
onloadedmetadata
=
function
()
{
clearTimeout
(
handle
);
video
.
onerror
=
null
;
resolve
({
size
:
file
?
file
.
size
:
void
0
,
duration
:
video
.
duration
||
0
,
width
:
video
.
videoWidth
||
0
,
height
:
video
.
videoHeight
||
0
});
};
video
.
onerror
=
function
()
{
clearTimeout
(
handle
);
video
.
onloadedmetadata
=
null
;
reject
();
};
video
.
src
=
src
;
}
else
{
reject
();
}
});
},
GetVideoInfoProtocol
,
GetVideoInfoOptions
);
const
MIMEType
=
{
const
MIMEType
=
{
image
:
{
image
:
{
jpg
:
"
jpeg
"
,
jpg
:
"
jpeg
"
,
...
@@ -12084,6 +12132,7 @@ var api = /* @__PURE__ */ Object.freeze({
...
@@ -12084,6 +12132,7 @@ var api = /* @__PURE__ */ Object.freeze({
getFileInfo
,
getFileInfo
,
openDocument
,
openDocument
,
getImageInfo
,
getImageInfo
,
getVideoInfo
,
chooseFile
,
chooseFile
,
chooseImage
,
chooseImage
,
chooseVideo
,
chooseVideo
,
...
@@ -13151,4 +13200,4 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
...
@@ -13151,4 +13200,4 @@ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
]);
]);
}
}
_sfc_main
.
render
=
_sfc_render
;
_sfc_main
.
render
=
_sfc_render
;
export
{
_sfc_main$1
as
AsyncErrorComponent
,
_sfc_main
as
AsyncLoadingComponent
,
_sfc_main$n
as
Audio
,
index$4
as
Button
,
_sfc_main$m
as
Canvas
,
_sfc_main$l
as
Checkbox
,
_sfc_main$k
as
CheckboxGroup
,
_sfc_main$j
as
Editor
,
index$5
as
Form
,
index$3
as
Icon
,
_sfc_main$h
as
Image
,
_sfc_main$g
as
Input
,
_sfc_main$f
as
Label
,
LayoutComponent
,
_sfc_main$e
as
MovableView
,
_sfc_main$d
as
Navigator
,
index
as
PageComponent
,
_sfc_main$c
as
Progress
,
_sfc_main$b
as
Radio
,
_sfc_main$a
as
RadioGroup
,
_sfc_main$i
as
ResizeSensor
,
_sfc_main$9
as
RichText
,
_sfc_main$8
as
ScrollView
,
_sfc_main$7
as
Slider
,
_sfc_main$6
as
SwiperItem
,
_sfc_main$5
as
Switch
,
index$2
as
Text
,
_sfc_main$4
as
Textarea
,
UniServiceJSBridge$1
as
UniServiceJSBridge
,
UniViewJSBridge$1
as
UniViewJSBridge
,
_sfc_main$3
as
Video
,
index$1
as
View
,
addInterceptor
,
arrayBufferToBase64
,
base64ToArrayBuffer
,
canIUse
,
chooseFile
,
chooseImage
,
chooseVideo
,
clearStorage
,
clearStorageSync
,
closeSocket
,
connectSocket
,
createIntersectionObserver
,
createSelectorQuery
,
createVideoContext
,
cssBackdropFilter
,
cssConstant
,
cssEnv
,
cssVar
,
downloadFile
,
getApp$1
as
getApp
,
getCurrentPages$1
as
getCurrentPages
,
getFileInfo
,
getImageInfo
,
getLocation
,
getNetworkType
,
getStorage
,
getStorageInfo
,
getStorageInfoSync
,
getStorageSync
,
getSystemInfo
,
getSystemInfoSync
,
hideLoading
,
hideNavigationBarLoading
,
hideTabBar
,
hideTabBarRedDot
,
hideToast
,
makePhoneCall
,
navigateBack
,
navigateTo
,
offAccelerometerChange
,
offCompassChange
,
offNetworkStatusChange
,
onAccelerometerChange
,
onCompassChange
,
onNetworkStatusChange
,
onSocketClose
,
onSocketError
,
onSocketMessage
,
onSocketOpen
,
onTabBarMidButtonTap
,
openDocument
,
index$6
as
plugin
,
promiseInterceptor
,
reLaunch
,
redirectTo
,
removeInterceptor
,
removeStorage
,
removeStorageSync
,
removeTabBarBadge
,
request
,
sendSocketMessage
,
setNavigationBarColor
,
setNavigationBarTitle
,
setStorage
,
setStorageSync
,
setTabBarBadge
,
setTabBarItem
,
setTabBarStyle
,
setupApp
,
setupPage
,
showActionSheet
,
showLoading
,
showModal
,
showNavigationBarLoading
,
showTabBar
,
showTabBarRedDot
,
showToast
,
startAccelerometer
,
startCompass
,
stopAccelerometer
,
stopCompass
,
switchTab
,
uni$1
as
uni
,
uploadFile
,
upx2px
,
usePageRoute
,
useSubscribe
};
export
{
_sfc_main$1
as
AsyncErrorComponent
,
_sfc_main
as
AsyncLoadingComponent
,
_sfc_main$n
as
Audio
,
index$4
as
Button
,
_sfc_main$m
as
Canvas
,
_sfc_main$l
as
Checkbox
,
_sfc_main$k
as
CheckboxGroup
,
_sfc_main$j
as
Editor
,
index$5
as
Form
,
index$3
as
Icon
,
_sfc_main$h
as
Image
,
_sfc_main$g
as
Input
,
_sfc_main$f
as
Label
,
LayoutComponent
,
_sfc_main$e
as
MovableView
,
_sfc_main$d
as
Navigator
,
index
as
PageComponent
,
_sfc_main$c
as
Progress
,
_sfc_main$b
as
Radio
,
_sfc_main$a
as
RadioGroup
,
_sfc_main$i
as
ResizeSensor
,
_sfc_main$9
as
RichText
,
_sfc_main$8
as
ScrollView
,
_sfc_main$7
as
Slider
,
_sfc_main$6
as
SwiperItem
,
_sfc_main$5
as
Switch
,
index$2
as
Text
,
_sfc_main$4
as
Textarea
,
UniServiceJSBridge$1
as
UniServiceJSBridge
,
UniViewJSBridge$1
as
UniViewJSBridge
,
_sfc_main$3
as
Video
,
index$1
as
View
,
addInterceptor
,
arrayBufferToBase64
,
base64ToArrayBuffer
,
canIUse
,
chooseFile
,
chooseImage
,
chooseVideo
,
clearStorage
,
clearStorageSync
,
closeSocket
,
connectSocket
,
createIntersectionObserver
,
createSelectorQuery
,
createVideoContext
,
cssBackdropFilter
,
cssConstant
,
cssEnv
,
cssVar
,
downloadFile
,
getApp$1
as
getApp
,
getCurrentPages$1
as
getCurrentPages
,
getFileInfo
,
getImageInfo
,
getLocation
,
getNetworkType
,
getStorage
,
getStorageInfo
,
getStorageInfoSync
,
getStorageSync
,
getSystemInfo
,
getSystemInfoSync
,
getVideoInfo
,
hideLoading
,
hideNavigationBarLoading
,
hideTabBar
,
hideTabBarRedDot
,
hideToast
,
makePhoneCall
,
navigateBack
,
navigateTo
,
offAccelerometerChange
,
offCompassChange
,
offNetworkStatusChange
,
onAccelerometerChange
,
onCompassChange
,
onNetworkStatusChange
,
onSocketClose
,
onSocketError
,
onSocketMessage
,
onSocketOpen
,
onTabBarMidButtonTap
,
openDocument
,
index$6
as
plugin
,
promiseInterceptor
,
reLaunch
,
redirectTo
,
removeInterceptor
,
removeStorage
,
removeStorageSync
,
removeTabBarBadge
,
request
,
sendSocketMessage
,
setNavigationBarColor
,
setNavigationBarTitle
,
setStorage
,
setStorageSync
,
setTabBarBadge
,
setTabBarItem
,
setTabBarStyle
,
setupApp
,
setupPage
,
showActionSheet
,
showLoading
,
showModal
,
showNavigationBarLoading
,
showTabBar
,
showTabBarRedDot
,
showToast
,
startAccelerometer
,
startCompass
,
stopAccelerometer
,
stopCompass
,
switchTab
,
uni$1
as
uni
,
uploadFile
,
upx2px
,
usePageRoute
,
useSubscribe
};
packages/uni-h5/src/service/api/index.ts
浏览文件 @
4553386d
...
@@ -13,6 +13,7 @@ export * from './file/getFileInfo'
...
@@ -13,6 +13,7 @@ export * from './file/getFileInfo'
export
*
from
'
./file/openDocument
'
export
*
from
'
./file/openDocument
'
export
*
from
'
./media/getImageInfo
'
export
*
from
'
./media/getImageInfo
'
export
*
from
'
./media/getVideoInfo
'
export
*
from
'
./media/chooseFile
'
export
*
from
'
./media/chooseFile
'
export
*
from
'
./media/chooseImage
'
export
*
from
'
./media/chooseImage
'
export
*
from
'
./media/chooseVideo
'
export
*
from
'
./media/chooseVideo
'
...
...
packages/uni-h5/src/service/api/media/getVideoInfo.ts
0 → 100644
浏览文件 @
4553386d
import
{
defineAsyncApi
,
API_GET_VIDEO_INFO
,
API_TYPE_GET_VIDEO_INFO
,
GetVideoInfoOptions
,
GetVideoInfoProtocol
,
}
from
'
@dcloudio/uni-api
'
import
{
urlToFile
}
from
'
../../../helpers/file
'
export
const
getVideoInfo
=
<
API_TYPE_GET_VIDEO_INFO
>
defineAsyncApi
(
API_GET_VIDEO_INFO
,
({
src
},
{
resolve
,
reject
})
=>
{
urlToFile
(
src
,
true
)
.
then
((
file
)
=>
{
return
file
})
.
catch
(()
=>
{
return
null
})
.
then
((
file
)
=>
{
const
video
=
document
.
createElement
(
'
video
'
)
if
(
video
.
onloadedmetadata
!==
undefined
)
{
// 部分浏览器(如微信内置浏览器)未播放无法触发loadedmetadata事件
const
handle
=
setTimeout
(
()
=>
{
video
.
onloadedmetadata
=
null
video
.
onerror
=
null
reject
()
},
src
.
startsWith
(
'
data:
'
)
||
src
.
startsWith
(
'
blob:
'
)
?
300
:
3000
)
// 尝试获取视频的宽高信息
video
.
onloadedmetadata
=
function
()
{
clearTimeout
(
handle
)
video
.
onerror
=
null
resolve
({
size
:
file
?
file
.
size
:
undefined
,
duration
:
video
.
duration
||
0
,
width
:
video
.
videoWidth
||
0
,
height
:
video
.
videoHeight
||
0
,
})
}
video
.
onerror
=
function
()
{
clearTimeout
(
handle
)
video
.
onloadedmetadata
=
null
reject
()
}
video
.
src
=
src
}
else
{
reject
()
}
})
},
GetVideoInfoProtocol
,
GetVideoInfoOptions
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录