Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
uni-app
提交
444813b3
U
uni-app
项目概览
DCloud
/
uni-app
29 天 前同步成功
通知
702
Star
38704
Fork
3642
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
7
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
U
uni-app
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
7
Issue
7
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
444813b3
编写于
1月 25, 2022
作者:
d-u-a
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
vue live-pusher
上级
ad81ca68
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
198 addition
and
4 deletion
+198
-4
src/platforms/app-plus/service/api/context/live-pusher.js
src/platforms/app-plus/service/api/context/live-pusher.js
+49
-4
src/platforms/app-plus/view/components/live-pusher/index.vue
src/platforms/app-plus/view/components/live-pusher/index.vue
+149
-0
未找到文件。
src/platforms/app-plus/service/api/context/live-pusher.js
浏览文件 @
444813b3
import
{
c
reateLivePusherContext
as
createLivePusher
}
from
'
uni-
platforms/app-plus-nvue/service/api/context/live-pusher
'
c
allback
}
from
'
uni-
shared
'
export
function
createLivePusherContext
(
id
,
vm
)
{
return
createLivePusher
(
id
,
vm
)
function
operateLivePusher
(
livePusherId
,
pageVm
,
type
,
data
)
{
const
pageId
=
pageVm
.
$page
.
id
UniServiceJSBridge
.
publishHandler
(
pageId
+
'
-live-pusher-
'
+
livePusherId
,
{
livePusherId
,
type
,
data
},
pageId
)
}
UniServiceJSBridge
.
subscribe
(
'
onLivePusherMethodCallback
'
,
({
callbackId
,
data
})
=>
{
callback
.
invoke
(
callbackId
,
data
)
})
const
methods
=
[
'
preview
'
,
'
start
'
,
'
stop
'
,
'
pause
'
,
'
resume
'
,
'
switchCamera
'
,
'
snapshot
'
]
export
class
LivePusherContext
{
constructor
(
id
,
pageVm
)
{
this
.
id
=
id
this
.
pageVm
=
pageVm
}
on
(
name
,
callback
)
{
operateLivePusher
(
this
.
id
,
this
.
pageVm
,
'
on
'
,
{
name
,
callback
})
}
}
methods
.
forEach
(
function
(
method
)
{
LivePusherContext
.
prototype
[
method
]
=
callback
.
warp
(
function
(
options
,
callbackId
)
{
options
.
callbackId
=
callbackId
operateLivePusher
(
this
.
id
,
this
.
pageVm
,
method
,
options
)
})
})
export
function
createLivePusherContext
(
id
,
context
)
{
return
new
LivePusherContext
(
id
,
context
)
}
src/platforms/app-plus/view/components/live-pusher/index.vue
0 → 100644
浏览文件 @
444813b3
<
template
>
<uni-live-pusher
v-on=
"$listeners"
>
<div
ref=
"container"
class=
"uni-live-pusher-container"
/>
<div
class=
"uni-live-pusher-slot"
>
<slot
/>
</div>
</uni-live-pusher>
</
template
>
<
script
>
import
{
subscriber
}
from
'
uni-mixins
'
import
native
from
'
../../mixins/native
'
const
methods
=
[
'
preview
'
,
'
start
'
,
'
stop
'
,
'
pause
'
,
'
resume
'
,
'
switchCamera
'
,
'
snapshot
'
]
const
events
=
[
'
statechange
'
,
'
netstatus
'
,
'
error
'
]
const
attrs
=
[
'
url
'
,
'
mode
'
,
'
muted
'
]
export
default
{
name
:
'
LivePusher
'
,
mixins
:
[
subscriber
,
native
],
props
:
{
id
:
{
type
:
String
,
default
:
''
},
url
:
{
type
:
String
,
default
:
''
},
mode
:
{
type
:
String
,
default
:
'
SD
'
},
muted
:
{
type
:
[
Boolean
,
String
],
default
:
false
}
},
computed
:
{
attrs
()
{
const
obj
=
{}
attrs
.
forEach
(
key
=>
{
let
val
=
this
.
$props
[
key
]
val
=
key
===
'
src
'
?
this
.
$getRealPath
(
val
)
:
val
obj
[
key
.
replace
(
/
[
A-Z
]
/g
,
str
=>
'
-
'
+
str
.
toLowerCase
())]
=
val
})
return
obj
}
},
mounted
()
{
this
.
_onParentReady
(()
=>
{
const
livePusher
=
this
.
livePusher
=
new
plus
.
video
.
LivePusher
(
'
livePusher
'
+
Date
.
now
(),
Object
.
assign
({},
this
.
attrs
,
this
.
position
))
plus
.
webview
.
currentWebview
().
append
(
livePusher
)
this
.
$watch
(
'
attrs
'
,
()
=>
{
this
.
livePusher
&&
this
.
livePusher
.
setStyles
(
this
.
attrs
)
},
{
deep
:
true
})
this
.
$watch
(
'
position
'
,
()
=>
{
this
.
livePusher
&&
this
.
livePusher
.
setStyles
(
this
.
position
)
},
{
deep
:
true
})
this
.
$watch
(
'
hidden
'
,
(
val
)
=>
{
const
livePusher
=
this
.
livePusher
if
(
livePusher
)
{
// livePusher[val ? 'hide' : 'show']()
// iOS 隐藏状态设置 setStyles 不生效
if
(
!
val
)
{
livePusher
.
setStyles
(
this
.
position
)
}
}
})
events
.
forEach
(
key
=>
{
livePusher
.
addEventListener
(
key
,
(
e
)
=>
{
this
.
$trigger
(
key
,
{},
{
...
e
.
detail
})
})
})
})
},
beforeDestroy
()
{
this
.
livePusher
&&
this
.
livePusher
.
close
()
delete
this
.
livePusher
},
methods
:
{
_handleSubscribe
({
type
,
data
=
{}
})
{
console
.
log
(
'
_handleSubscribe type::
'
+
type
)
if
(
methods
.
includes
(
type
))
{
this
.
livePusher
&&
this
.
livePusher
[
type
](
data
)
}
}
}
}
</
script
>
<
style
>
uni-live-pusher
{
width
:
300px
;
height
:
225px
;
display
:
inline-block
;
line-height
:
0
;
overflow
:
hidden
;
position
:
relative
;
}
uni-live-pusher
[
hidden
]
{
display
:
none
;
}
.uni-live-pusher-container
{
width
:
100%
;
height
:
100%
;
position
:
absolute
;
top
:
0
;
left
:
0
;
overflow
:
hidden
;
background-color
:
black
;
}
.uni-live-pusher-slot
{
position
:
absolute
;
top
:
0
;
width
:
100%
;
height
:
100%
;
overflow
:
hidden
;
pointer-events
:
none
;
}
</
style
>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录