提交 b863a8e1 编写于 作者: d-u-a's avatar d-u-a

feat(app-vue): 支持 live-pusher 组件

上级 cbdeeb47
......@@ -4,7 +4,7 @@ import {
function operateLivePusher (livePusherId, pageVm, type, data) {
const pageId = pageVm.$page.id
UniServiceJSBridge.publishHandler(pageId + '-live-pusher-' + livePusherId, {
UniServiceJSBridge.publishHandler(pageId + '-livepusher-' + livePusherId, {
livePusherId,
type,
data
......@@ -18,13 +18,21 @@ UniServiceJSBridge.subscribe('onLivePusherMethodCallback', ({
callback.invoke(callbackId, data)
})
const methods = ['preview',
const methods = [
'start',
'stop',
'pause',
'resume',
'switchCamera',
'snapshot']
'startPreview',
'stopPreview',
'snapshot'
]
const methodMapping = {
startPreview: 'preview',
stopPreview: 'stop'
}
export class LivePusherContext {
constructor (id, pageVm) {
......@@ -43,7 +51,8 @@ export class LivePusherContext {
methods.forEach(function (method) {
LivePusherContext.prototype[method] = callback.warp(function (options, callbackId) {
options.callbackId = callbackId
operateLivePusher(this.id, this.pageVm, method, options)
const methodName = methodMapping[method] ? methodMapping[method] : method
operateLivePusher(this.id, this.pageVm, methodName, options)
})
})
......
......@@ -15,16 +15,6 @@ import {
} from 'uni-mixins'
import native from '../../mixins/native'
const methods = [
'preview',
'start',
'stop',
'pause',
'resume',
'switchCamera',
'snapshot'
]
const events = [
'statechange',
'netstatus',
......@@ -34,17 +24,19 @@ const events = [
const attrs = [
'url',
'mode',
'muted'
'muted',
'enableCamera',
'autoFocus',
'beauty',
'whiteness',
'aspect',
'minBitrate'
]
export default {
name: 'LivePusher',
mixins: [subscriber, native],
props: {
id: {
type: String,
default: ''
},
url: {
type: String,
default: ''
......@@ -56,6 +48,30 @@ export default {
muted: {
type: [Boolean, String],
default: false
},
enableCamera: {
type: [Boolean, String],
default: true
},
autoFocus: {
type: [Boolean, String],
default: true
},
beauty: {
type: [Number, String],
default: 0
},
whiteness: {
type: [Number, String],
default: 0
},
aspect: {
type: [String],
default: '3:2'
},
minBitrate: {
type: [Number],
default: 200
}
},
computed: {
......@@ -105,10 +121,7 @@ export default {
type,
data = {}
}) {
console.log('_handleSubscribe type::' + type)
if (methods.includes(type)) {
this.livePusher && this.livePusher[type](data)
}
this.livePusher && this.livePusher[type](data)
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册