/pages/push/push_config.vue (直播设置页)
@change="orientationChange">
:active-color="activeColor" @change="devicePositionChange">
{{form.beauty}} 级
{{form.whiteness}} 级
export default {
data() {
return {
activeColor: "#2979ff",
mode_select: [{
value: 'SD',
name: '标清'
},
{
value: 'HD',
name: '高清'
},
{
value: 'FHD',
name: '超清'
}
],
orientation_select: [{
value: 'vertical',
name: '垂直方向'
},
{
value: 'horizontal',
name: '水平方向'
}
],
devicePosition_select: [{
value: 'front',
name: '前置摄像'
},
{
value: 'back',
name: '后置摄像'
}
],
witch_select: [{
value: true,
name: '开启'
},
{
value: false,
name: '关闭'
}
],
form: {
push_url: 'rtmp://vpush.qdd88.cn/live/621FD133-889D-1707-CF0E-83A8A715D412?auth_key=1604793600-0-0-a23b8d96c6223cf29f001b461758bd53', // 推流地址
mode: 'FHD', // 视频模式
autoFocus: true, // 自动对焦
zoom: true, // 远近焦距
beauty: 30, // 美颜级别 0-100
whiteness: 30, // 美白级别 0-100
orientation: 'vertical', // 画面方向
devicePosition: 'front' // 摄像方向
}
}
},
computed: {
// 获取当前选项列表下标
getCurrent() {
return (select_name, form_name) => {
let select_object = this[select_name]
let active_value = this['form'][form_name]
if (select_object && active_value) {
for (let i in this[select_name]) {
if (select_object[i]['value'] == active_value) {
return i
}
}
return 0
}
}
}
},
methods: {
modeChange(index) {
let value = this.mode_select[index]['value']
if (value)
this.$set(this.form, 'mode', value)
},
orientationChange(index) {
let value = this.orientation_select[index]['value']
if (value)
this.$set(this.form, 'orientation', value)
},
devicePositionChange(index) {
let value = this.devicePosition_select[index]['value']
if (value)
this.$set(this.form, 'devicePosition', value)
},
launchPusher() {
let query = '?'
let params = this.form
for (let key in params) {
query += `${key}=${params[key]}&`
}
query = query.replace(/&$/, '')
uni.navigateTo({
url: './push_weex' + query
})
}
}
}
/pages/push/push.nvue (推流界面页)
:orientation="orientation" :muted="muted" :beauty="beauty" :whiteness="whiteness" :remote-mirror="remoteMirror"
:auto-focus="autoFocus" :zoom="zoom" :style="{height: windowHeight}" @statechange="statechange" @netstatus="netstatus"
@error="error">
export default {
data() {
return {
url: '',
enableCamera: true,
pusher: null,
isPushing: false,
windowHeight: '0px',
orientation: 'vertical',
devicePosition: 'front',
mode: 'FHD',
muted: false,
beauty: 0,
whiteness: 0,
zoom: true,
autoFocus: true,
remoteMirror: true
};
},
onLoad(options) {
this.url = options.push_url
this.orientation = options.orientation
this.devicePosition = options.devicePosition
this.mode = options.mode
this.beauty = options.beauty / 10
this.whiteness = options.whiteness / 10
this.zoom = options.zoom
this.autoFocus = options.autoFocus
},
onReady() {
this.windowHeight = uni.getSystemInfoSync().windowHeight + 'px';
this.pusher = uni.createLivePusherContext('livePusher', this);
this.pusher.startPreview()
uni.$on('onStart', this.onStart)
uni.$on('onSwitchCamera', this.onSwitchCamera)
uni.$on('onMuted', this.onMuted)
},
methods: {
onStart() {
this.isPushing = !this.isPushing
if (this.isPushing) {
this.pusher.start()
} else {
this.pusher.pause()
}
},
onSwitchCamera() {
this.pusher.switchCamera()
},
onMuted() {
this.muted = !this.muted
},
statechange(e) {
console.log("statechange:" + JSON.stringify(e));
},
netstatus(e) {
console.log("netstatus:" + JSON.stringify(e));
},
error(e) {
console.log("error:" + JSON.stringify(e));
}
}
};