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

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

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