Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
wychl
uni-app
提交
c9b4b6c9
U
uni-app
项目概览
wychl
/
uni-app
与 Fork 源项目一致
Fork自
DCloud / uni-app
通知
1
Star
0
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,发现更多精彩内容 >>
提交
c9b4b6c9
编写于
4月 15, 2021
作者:
Q
qiang
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'dev' into alpha
上级
4ca08ec2
aab5fa6a
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
194 addition
and
230 deletion
+194
-230
docs/api/media/video.md
docs/api/media/video.md
+12
-12
src/platforms/app-plus/service/api/ad/ad-base.js
src/platforms/app-plus/service/api/ad/ad-base.js
+156
-0
src/platforms/app-plus/service/api/ad/full-screen-video-ad.js
...platforms/app-plus/service/api/ad/full-screen-video-ad.js
+5
-98
src/platforms/app-plus/service/api/ad/interstitial-ad.js
src/platforms/app-plus/service/api/ad/interstitial-ad.js
+6
-106
src/platforms/app-plus/service/api/media/choose-image.js
src/platforms/app-plus/service/api/media/choose-image.js
+3
-3
src/platforms/app-plus/service/api/media/choose-video.js
src/platforms/app-plus/service/api/media/choose-video.js
+12
-11
未找到文件。
docs/api/media/video.md
浏览文件 @
c9b4b6c9
...
...
@@ -241,7 +241,7 @@ export default {
|App|H5|微信小程序|支付宝小程序|百度小程序|字节跳动小程序|QQ小程序|
|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
|
x|x
|2.11.0+|x|x|x|x|
|
3.1.10+|3.1.10+
|2.11.0+|x|x|x|x|
**OBJECT 参数说明**
...
...
@@ -254,16 +254,16 @@ export default {
**success 返回参数说明**
|参数名 |类型 |说明 |
|:- |:- |:- |
|orientation|string |画面方向 |
|type |string |视频格式 |
|duration |number |视频长度 |
|size |number |视频大小,单位 kB |
|height |number |视频的长,单位 px |
|width |number |视频的宽,单位 px |
|fps |number |视频帧率 |
|bitrate |number |视频码率,单位 kbps|
|参数名 |类型 |说明 |
平台差异说明|
|:- |:- |:- |
|
|orientation|string |画面方向 |
微信小程序|
|type |string |视频格式 |
微信小程序|
|duration |number |视频长度 |
微信小程序、App、H5|
|size |number |视频大小,单位 kB |
微信小程序、App、H5|
|height |number |视频的长,单位 px |
微信小程序、App、H5|
|width |number |视频的宽,单位 px |
微信小程序、App、H5|
|fps |number |视频帧率 |
微信小程序、App|
|bitrate |number |视频码率,单位 kbps|
微信小程序|
**res.orientation参数说明**
...
...
@@ -286,7 +286,7 @@ export default {
|App|H5|微信小程序|支付宝小程序|百度小程序|字节跳动小程序|QQ小程序|
|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
|
x
|x|2.11.0+|x|x|x|x|
|
3.1.10+
|x|2.11.0+|x|x|x|x|
App端有很多插件支持视频压缩,详见
[
插件市场
](
https://ext.dcloud.net.cn/search?q=%E8%A7%86%E9%A2%91%E5%8E%8B%E7%BC%A9
)
...
...
src/platforms/app-plus/service/api/ad/ad-base.js
0 → 100644
浏览文件 @
c9b4b6c9
const
eventTypes
=
{
load
:
'
load
'
,
close
:
'
close
'
,
error
:
'
error
'
,
adClicked
:
'
adClicked
'
}
const
eventNames
=
[
eventTypes
.
load
,
eventTypes
.
close
,
eventTypes
.
error
,
eventTypes
.
adClicked
]
class
AdBase
{
constructor
(
adInstance
,
options
)
{
const
_callbacks
=
this
.
_callbacks
=
{}
eventNames
.
forEach
(
item
=>
{
_callbacks
[
item
]
=
[]
const
name
=
item
[
0
].
toUpperCase
()
+
item
.
substr
(
1
)
this
[
`on
${
name
}
`
]
=
function
(
callback
)
{
_callbacks
[
item
].
push
(
callback
)
}
})
this
.
_preload
=
options
.
preload
!==
undefined
?
options
.
preload
:
false
this
.
_isLoaded
=
false
this
.
_isLoading
=
false
this
.
_adError
=
''
this
.
_loadPromiseResolve
=
null
this
.
_loadPromiseReject
=
null
this
.
_showPromiseResolve
=
null
this
.
_showPromiseReject
=
null
const
ad
=
this
.
_ad
=
adInstance
ad
.
onLoad
((
e
)
=>
{
this
.
_isLoaded
=
true
this
.
_isLoading
=
false
this
.
_dispatchEvent
(
eventTypes
.
load
,
{})
if
(
this
.
_loadPromiseResolve
!=
null
)
{
this
.
_loadPromiseResolve
()
this
.
_loadPromiseResolve
=
null
}
if
(
this
.
_showPromiseResolve
!=
null
)
{
this
.
_showPromiseResolve
()
this
.
_showPromiseResolve
=
null
this
.
_showAd
()
}
})
ad
.
onClose
((
e
)
=>
{
this
.
_isLoaded
=
false
this
.
_isLoading
=
false
this
.
_dispatchEvent
(
eventTypes
.
close
,
{
isEnded
:
e
.
isEnded
})
if
(
this
.
_preload
===
true
)
{
this
.
_loadAd
()
}
})
ad
.
onError
((
e
)
=>
{
this
.
_isLoading
=
false
const
data
=
{
code
:
e
.
code
,
errMsg
:
e
.
message
}
this
.
_adError
=
data
this
.
_dispatchEvent
(
eventTypes
.
error
,
data
)
const
promiseError
=
new
Error
(
JSON
.
stringify
(
this
.
_adError
))
promiseError
.
code
=
e
.
code
promiseError
.
errMsg
=
e
.
message
if
(
this
.
_loadPromiseReject
!=
null
)
{
this
.
_loadPromiseReject
(
promiseError
)
this
.
_loadPromiseReject
=
null
}
if
(
this
.
_showPromiseReject
!=
null
)
{
this
.
_showPromiseReject
(
promiseError
)
this
.
_showPromiseReject
=
null
}
})
ad
.
onAdClicked
&&
ad
.
onAdClicked
((
e
)
=>
{
this
.
_dispatchEvent
(
eventTypes
.
adClicked
,
{})
})
}
load
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
_loadPromiseResolve
=
resolve
this
.
_loadPromiseReject
=
reject
if
(
this
.
_isLoading
)
{
return
}
if
(
this
.
_isLoaded
)
{
resolve
()
}
else
{
this
.
_loadAd
()
}
})
}
show
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
_showPromiseResolve
=
resolve
this
.
_showPromiseReject
=
reject
if
(
this
.
_isLoading
)
{
return
}
if
(
this
.
_isLoaded
)
{
this
.
_showAd
()
resolve
()
}
else
{
this
.
_loadAd
()
}
})
}
destroy
()
{
this
.
_ad
.
destroy
()
}
getProvider
()
{
return
this
.
_ad
.
getProvider
()
}
_loadAd
()
{
this
.
_adError
=
''
this
.
_isLoaded
=
false
this
.
_isLoading
=
true
this
.
_ad
.
load
()
}
_showAd
()
{
this
.
_ad
.
show
()
}
_dispatchEvent
(
name
,
data
)
{
this
.
_callbacks
[
name
].
forEach
(
callback
=>
{
if
(
typeof
callback
===
'
function
'
)
{
callback
(
data
||
{})
}
})
}
}
export
{
AdBase
}
src/platforms/app-plus/service/api/ad/full-screen-video-ad.js
浏览文件 @
c9b4b6c9
const
eventNames
=
[
'
load
'
,
'
close
'
,
'
error
'
,
'
adClicked
'
]
import
{
AdBase
}
from
'
./ad-base.js
'
class
FullScreenVideoAd
{
class
FullScreenVideoAd
extends
AdBase
{
constructor
(
options
=
{})
{
const
_callbacks
=
this
.
_callbacks
=
{}
eventNames
.
forEach
(
item
=>
{
_callbacks
[
item
]
=
[]
const
name
=
item
[
0
].
toUpperCase
()
+
item
.
substr
(
1
)
this
[
`on
${
name
}
`
]
=
function
(
callback
)
{
_callbacks
[
item
].
push
(
callback
)
}
})
this
.
_isLoad
=
false
this
.
_adError
=
''
this
.
_loadPromiseResolve
=
null
this
.
_loadPromiseReject
=
null
this
.
_lastLoadTime
=
0
const
ad
=
this
.
_ad
=
plus
.
ad
.
createFullScreenVideoAd
(
options
)
ad
.
onLoad
((
e
)
=>
{
this
.
_isLoad
=
true
this
.
_lastLoadTime
=
Date
.
now
()
this
.
_dispatchEvent
(
'
load
'
,
{})
if
(
this
.
_loadPromiseResolve
!=
null
)
{
this
.
_loadPromiseResolve
()
this
.
_loadPromiseResolve
=
null
}
})
ad
.
onClose
((
e
)
=>
{
this
.
_isLoad
=
false
this
.
_dispatchEvent
(
'
close
'
,
{
isEnded
:
e
.
isEnded
})
})
ad
.
onError
((
e
)
=>
{
const
{
code
,
message
}
=
e
const
data
=
{
code
:
code
,
errMsg
:
message
}
this
.
_adError
=
message
if
(
code
===
-
5008
)
{
this
.
_isLoad
=
false
}
this
.
_dispatchEvent
(
'
error
'
,
data
)
if
(
this
.
_loadPromiseReject
!=
null
)
{
this
.
_loadPromiseReject
(
data
)
this
.
_loadPromiseReject
=
null
}
})
ad
.
onAdClicked
((
e
)
=>
{
this
.
_dispatchEvent
(
'
adClicked
'
,
{})
})
}
load
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
this
.
_isLoad
)
{
resolve
()
return
}
this
.
_loadPromiseResolve
=
resolve
this
.
_loadPromiseReject
=
reject
this
.
_loadAd
()
})
}
show
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
this
.
_isLoad
)
{
this
.
_ad
.
show
()
resolve
()
}
else
{
reject
(
new
Error
(
this
.
_adError
))
}
})
}
getProvider
()
{
return
this
.
_ad
.
getProvider
()
}
destroy
()
{
this
.
_ad
.
destroy
()
}
_loadAd
()
{
this
.
_isLoad
=
false
this
.
_ad
.
load
()
}
_dispatchEvent
(
name
,
data
)
{
this
.
_callbacks
[
name
].
forEach
(
callback
=>
{
if
(
typeof
callback
===
'
function
'
)
{
callback
(
data
||
{})
}
})
super
(
plus
.
ad
.
createFullScreenVideoAd
(
options
),
options
)
}
}
...
...
src/platforms/app-plus/service/api/ad/interstitial-ad.js
浏览文件 @
c9b4b6c9
const
eventNames
=
[
'
load
'
,
'
close
'
,
'
error
'
,
'
adClicked
'
]
import
{
AdBase
}
from
'
./ad-base.js
'
class
InterstitialAd
{
class
InterstitialAd
extends
AdBase
{
constructor
(
options
=
{})
{
const
_callbacks
=
this
.
_callbacks
=
{}
eventNames
.
forEach
(
item
=>
{
_callbacks
[
item
]
=
[]
const
name
=
item
[
0
].
toUpperCase
()
+
item
.
substr
(
1
)
this
[
`on
${
name
}
`
]
=
function
(
callback
)
{
_callbacks
[
item
].
push
(
callback
)
}
})
super
(
plus
.
ad
.
createInterstitialAd
(
options
),
options
)
this
.
_isLoad
=
false
this
.
_isLoading
=
false
this
.
_adError
=
''
this
.
_loadPromiseResolve
=
null
this
.
_loadPromiseReject
=
null
const
ad
=
this
.
_ad
=
plus
.
ad
.
createInterstitialAd
(
options
)
ad
.
onLoad
((
e
)
=>
{
this
.
_isLoad
=
true
this
.
_isLoading
=
false
this
.
_dispatchEvent
(
'
load
'
,
{})
if
(
this
.
_loadPromiseResolve
!=
null
)
{
this
.
_loadPromiseResolve
()
this
.
_loadPromiseResolve
=
null
}
})
ad
.
onClose
((
e
)
=>
{
this
.
_isLoad
=
false
this
.
_isLoading
=
false
this
.
_dispatchEvent
(
'
close
'
,
{})
})
ad
.
onError
((
e
)
=>
{
this
.
_isLoading
=
false
const
{
code
,
message
}
=
e
const
data
=
{
code
:
code
,
errMsg
:
message
}
this
.
_adError
=
message
this
.
_dispatchEvent
(
'
error
'
,
data
)
if
(
this
.
_loadPromiseReject
!=
null
)
{
this
.
_loadPromiseReject
(
data
)
this
.
_loadPromiseReject
=
null
}
})
ad
.
onAdClicked
((
e
)
=>
{
this
.
_dispatchEvent
(
'
adClicked
'
,
{})
})
}
load
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
this
.
_loadPromiseResolve
=
resolve
this
.
_loadPromiseReject
=
reject
if
(
this
.
_isLoading
)
{
return
}
if
(
this
.
_isLoad
)
{
resolve
()
return
}
this
.
_loadAd
()
})
}
show
()
{
return
new
Promise
((
resolve
,
reject
)
=>
{
if
(
this
.
_isLoading
)
{
return
}
if
(
this
.
_isLoad
)
{
this
.
_ad
.
show
()
resolve
()
}
else
{
reject
(
new
Error
(
this
.
_adError
))
}
})
}
getProvider
()
{
return
this
.
_ad
.
getProvider
()
}
destroy
()
{
this
.
_ad
.
destroy
()
}
_loadAd
()
{
this
.
_isLoad
=
false
this
.
_isLoading
=
true
this
.
_ad
.
load
()
}
_dispatchEvent
(
name
,
data
)
{
this
.
_callbacks
[
name
].
forEach
(
callback
=>
{
if
(
typeof
callback
===
'
function
'
)
{
callback
(
data
||
{})
}
})
this
.
load
()
}
}
...
...
src/platforms/app-plus/service/api/media/choose-image.js
浏览文件 @
c9b4b6c9
...
...
@@ -30,7 +30,7 @@ function getFileInfo (filePath) {
function
compressImage
(
tempFilePath
)
{
const
dstPath
=
`
${
TEMP_PATH
}
/compressed/
${
Date
.
now
()}
_
${
getFileName
(
tempFilePath
)}
`
return
new
Promise
((
resolve
,
reject
)
=>
{
return
new
Promise
((
resolve
)
=>
{
plus
.
nativeUI
.
showWaiting
()
plus
.
zip
.
compressImage
({
src
:
tempFilePath
,
...
...
@@ -39,9 +39,9 @@ function compressImage (tempFilePath) {
},
()
=>
{
plus
.
nativeUI
.
closeWaiting
()
resolve
(
dstPath
)
},
(
error
)
=>
{
},
()
=>
{
plus
.
nativeUI
.
closeWaiting
()
re
ject
(
error
)
re
solve
(
tempFilePath
)
})
})
}
...
...
src/platforms/app-plus/service/api/media/choose-video.js
浏览文件 @
c9b4b6c9
...
...
@@ -25,16 +25,20 @@ export function chooseVideo ({
function
successCallback
(
tempFilePath
=
''
)
{
const
dst
=
`
${
TEMP_PATH
}
/compressed/
${
Date
.
now
()}
_
${
getFileName
(
tempFilePath
)}
`
const
compressVideo
=
compressed
?
plus
.
zip
.
compressVideo
:
function
(
_
,
callback
)
{
callback
({
tempFilePath
})
}
const
compressVideo
=
compressed
?
new
Promise
((
resolve
)
=>
{
plus
.
zip
.
compressVideo
({
src
:
tempFilePath
,
dst
},
({
tempFilePath
})
=>
{
resolve
(
tempFilePath
)
},
()
=>
{
resolve
(
tempFilePath
)
})
})
:
Promise
.
resolve
()
if
(
compressed
)
{
plus
.
nativeUI
.
showWaiting
()
}
compressVideo
({
src
:
tempFilePath
,
dst
},
({
tempFilePath
})
=>
{
compressVideo
.
then
(
tempFilePath
=>
{
if
(
compressed
)
{
plus
.
nativeUI
.
closeWaiting
()
}
...
...
@@ -50,12 +54,9 @@ export function chooseVideo ({
result
.
width
=
videoInfo
.
width
result
.
height
=
videoInfo
.
height
invoke
(
callbackId
,
result
)
},
},
errorCallback
})
},
error
=>
{
plus
.
nativeUI
.
closeWaiting
()
errorCallback
(
error
)
})
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录