export default {
data() {
return {
src: ''
}
},
onLoad(options) {
// #ifdef APP-PLUS
// 强制横屏
plus.screen.lockOrientation('landscape')
// 保持屏幕常亮
uni.setKeepScreenOn({
keepScreenOn: true
});
// 保持全屏,无状态栏
plus.navigator.setFullscreen(true)
// 隐藏手机底部导航按键
plus.navigator.hideSystemNavigation()
// #endif
},
onReady() {
// 注意:需要在onReady中 或 onLoad 延时
this.context = uni.createLivePusherContext("livePusher", this);
this.startPreview()
},
onUnload() {
// #ifdef APP-PLUS
// 恢复竖屏
plus.screen.lockOrientation('portrait-primary');
// 关闭保持屏幕常亮
uni.setKeepScreenOn({
keepScreenOn: false
})
// 恢复状态栏
plus.navigator.setFullscreen(false)
// 显示手机底部导航按键
plus.navigator.showSystemNavigation()
// #endif
},
methods: {
startPreview: function() {
this.context.startPreview({
success: (a) => {
console.log("livePusher.startPreview:" + JSON.stringify(a));
}
});
console.log('123' + plus.navigator.isFullscreen())
},
getCamera() {
var cmr = plus.camera.getCamera(1);
console.log('cmr' + JSON.stringify(cmr))
// plus.navigator.setFullscreen(true);
// console.log('123' + plus.navigator.isFullscreen())
setTimeout(() => {
const cameraView = this.$refs.cameraView;
// 将摄像头画面渲染到页面上的 view 元素中
cameraView.$el.appendChild(cmr.stream, 'pop-in');
}, 1000)
},
}
}