t***@hotmail.com
t***@hotmail.com
  • 发布:2024-07-31 11:44
  • 更新:2024-11-19 10:49
  • 阅读:391

在ios中使用媒体组件live-pusher,控制横屏之后,摄像机拍摄内容旋转了-90°,使用orientation属性修改画面方向都没有用

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: win10

HBuilderX类型: 正式

HBuilderX版本号: 4.24

手机系统: iOS

手机系统版本号: iOS 15

手机厂商: 苹果

手机机型: iPhone12,1 (A2223)

页面类型: vue

vue版本: vue2

打包方式: 云端

项目创建方式: HBuilderX

操作步骤:
<template>  

    <view>  
        <live-pusher id='livePusher' ref="livePusher" class="livePusher" url="" mode="SD" :muted="true"  
            :enable-camera="true" :auto-focus="true" :orientation="'horizontal'" :beauty="1" whiteness="2" aspect="9:16"  
            @statechange="statechange" @netstatus="netstatus" @error="error"></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 {}  
        },  
        onReady() {  
            // 注意:需要在onReady中 或 onLoad 延时  
            this.context = uni.createLivePusherContext("livePusher", this);  
        },  
        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>  

<style>  

</style>  

预期结果:

摄像机预览的内容应随着屏幕的横屏或竖屏都应该是正的

实际结果:

摄像机预览的内容没有起到任何变化

bug描述:

在ios上使用媒体组件 live-pusher 开启摄像头预览 使用orientation属性horizontal 没有将预览的内容水平处理,而将页面通过plus.screen.lockOrientation('landscape-primary'); 固定横屏后,拍摄的内容被旋转了-90°,使用orientation没有起到任何作用

<template>  

    <view>  
        <live-pusher id='livePusher' ref="livePusher" class="livePusher" url="" mode="SD" :muted="true"  
            :enable-camera="true" :auto-focus="true" :orientation="'horizontal'" :beauty="1" whiteness="2" aspect="9:16"  
            @statechange="statechange" @netstatus="netstatus" @error="error"></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 {}  
        },  
        onReady() {  
            // 注意:需要在onReady中 或 onLoad 延时  
            this.context = uni.createLivePusherContext("livePusher", this);  
        },  
        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>  

<style>  

</style>
2024-07-31 11:44 负责人:无 分享
已邀请:
t***@hotmail.com

t***@hotmail.com (作者)

摄像机预览的内容不应该是反的

BFC

BFC

你好,nvue相关组件已经不维护了。可以去插件市场选一个uts直播插件

2***@qq.com

2***@qq.com

你好,你这个问题解决了吗

要回复问题请先登录注册