vr-shopxo-uniapp/pages/plugins/live/push/push.vue

123 lines
3.9 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template>
<view>
<live-pusher
id='livePusher'
ref="livePusher"
class="livePusher"
:url="url"
mode="SD"
:muted="false"
:enable-camera="true"
:auto-focus="true"
:beauty="1"
whiteness="2"
aspect="9:16"
@statechange="statechange"
@netstatus="netstatus"
@error = "error"
style="width: 100%;height: 500px;"
></live-pusher>
<button class="btn" @click="start"></button>
<button class="btn" @click="pause"></button>
<button class="btn" @click="resume">resume</button>
<button class="btn" @click="stop"></button>
<button class="btn" @click="snapshot"></button>
<button class="btn" @click="startPreview"></button>
<button class="btn" @click="stopPreview"></button>
<button class="btn" @click="switchCamera"></button>
</view>
</template>
<script>
export default {
data() {
return {
context: null,
url: "rtmp://live-push.shopxo.vip/68f764013572f9240ca7ce6c/shopxo"
}
},
onReady() {
// 注意需要在onReady中 或 onLoad 延时
var self = this;
setTimeout(function() {
self.context = uni.createLivePusherContext("livePusher", self);
}, 2000);
},
methods: {
statechange(e) {
console.log("statechange:" + JSON.stringify(e));
},
netstatus(e) {
console.log("netstatus:" + JSON.stringify(e));
},
error(e) {
console.log("error:" + JSON.stringify(e));
},
start: function() {
this.context.start({
success: (a) => {
console.log("livePusher.start:" + JSON.stringify(a));
}
});
},
close: function() {
this.context.close({
success: (a) => {
console.log("livePusher.close:" + JSON.stringify(a));
}
});
},
snapshot: function() {
this.context.snapshot({
success: (e) => {
console.log(JSON.stringify(e));
}
});
},
resume: function() {
this.context.resume({
success: (a) => {
console.log("livePusher.resume:" + JSON.stringify(a));
}
});
},
pause: function() {
this.context.pause({
success: (a) => {
console.log("livePusher.pause:" + JSON.stringify(a));
}
});
},
stop: function() {
this.context.stop({
success: (a) => {
console.log(JSON.stringify(a));
}
});
},
switchCamera: function() {
this.context.switchCamera({
success: (a) => {
console.log("livePusher.switchCamera:" + JSON.stringify(a));
}
});
},
startPreview: function() {
this.context.startPreview({
success: (a) => {
console.log("livePusher.startPreview:" + JSON.stringify(a));
}
});
},
stopPreview: function() {
this.context.stopPreview({
success: (a) => {
console.log("livePusher.stopPreview:" + JSON.stringify(a));
}
});
}
}
}
</script>