vvipLin
vvipLin
  • 发布:2021-01-18 15:45
  • 更新:2022-07-01 11:19
  • 阅读:4063

uniapp nvue界面使用live-pusher时遇到如下问题:

分类:uni-app

uniapp nvue界面使用live-pusher时遇到如下问题:

app端:
1.ios live-pusher横屏界面plus.screen.lockOrientation("landscape")后。摄像头画面方向正常。
2.Android live-pusher横屏界面plus.screen.lockOrientation("landscape")后。摄像头画面顺时针旋转了90度。
3.android顺时针旋转90度后推流,此时使用video拉取到的视频流画面旋转了180度。 即使,用vlc的pc端播放器查看视频流,也是旋转了180度的。

hbuilderX版本: 3.0.5
android: 测试2款安卓手机 6.0.1 以及 10.0,均有此问题。
ios: iphone6 plus 12.4

代码中未使用plus.video,而使用的uni.createLivePusherContext创建的视频

<live-pusher id='livePusher' ref="livePusher" class="livePusher"   
            :url="videoOptions.url"   
            :mode="videoOptions.mode"   
            :aspect="videoOptions.aspect"   
            :muted="videoOptions.muted"   
            :enable-camera="videoOptions['enable-camera']"   
            :auto-focus="videoOptions['auto-focus']"   
            :beauty="videoOptions.beauty"   
            :whiteness="videoOptions.whiteness"   
            :min-bitrate="videoOptions['min-bitrate']"   
            :max-bitrate="videoOptions['max-bitrate']"   
            :orientation="videoOptions.orientation"   
            @statechange="statechange"   
            @netstatus="netstatus"   
            @error="error">  
        </live-pusher>

live-pusher配置:

videoOptions: {  
url: "", //推流地址,支持RTMP协议。  
mode: "FHD", //推流视频模式,可取值:SD(标清), HD(高清), FHD(超清)  
aspect: "9:16", //"2:3"视频宽高比例  
muted: false, //是否静音。  
"enable-camera": true, //开启摄像头  
"auto-focus": true, //自动聚集  
beauty: 0, //美颜,取值范围 0-9(iOS取值范围为1) ,0 表示关闭  
whiteness: 0, //美白,取值范围 0-9(iOS取值范围为1) ,0 表示关闭  
orientation: "horizontal", //"vertical",“horizontal”画面方向  
"min-bitrate": 200, //最小码率  
"max-bitrate": 1000, //最小码率  
}
2021-01-18 15:45 负责人:DCloud_Android_DQQ 分享
已邀请:
s***@163.com

s***@163.com - 李杨

真好 我原本线上是好的 您一更新 我崩了啊。。。。。。。。

DCloud_Android_DQQ

DCloud_Android_DQQ

收到 我测试一下

  • 4***@qq.com

    live-pusher如何关闭并不调用麦克风权限呢

    2022-02-18 13:47

DCloud_Android_DQQ

DCloud_Android_DQQ

而使用的uni.createLivePusherContext创建的视频

这部分代码也贴一下吧。

  • vvipLin (作者)

    onReady() {

    // 注意:需要在onReady中 或 onLoad 延时

    uni.showLoading({

    title: '准备中...',

    mask: true

    });

    this.context = uni.createLivePusherContext("livePusher", this);

    setTimeout(function() {

    self.startPreview();

    }, 3000)

    },

    onShow() {

    // #ifdef APP-PLUS

    plus.screen.lockOrientation("landscape");

    // #endif

    },

    onLoad() {

    self = this;

    self.initEvents();

    },

    onBackPress(options) {

    // #ifdef APP-PLUS

    console.log("options.from=="+JSON.stringify(options));

    if(plus.os.name == 'Android' && options.from === 'backbutton'){

    console.log("安卓实体返回键");

    return true;

    }

    // #endif

    },

    methods: {

    initEvents: function(){

    // #ifdef APP-PLUS

    var page = this.$scope.$getAppWebview();

    page.setStyle({ popGesture: 'none' });

    console.log("关闭了侧滑返回");

    // #endif

    },

    goback: function() {

    if(self.isPlaying){

    uni.showModal({

    title: "直播中",

    content: "当前正在直播,是否关闭直播并退出?",

    showCancel: true,

    confirmText: "退出",

    confirmColor: "#FFB82A",

    cancelText: "取消",

    cancelColor: "#000000",

    success: function (res) {

    if (res.confirm) {

    self.stop();

    }

    }

    });

    }else{

    plus.screen.lockOrientation("portrait-primary");

    uni.navigateBack();

    }

    },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() {

    uni.showLoading({

    title: "正在开启直播"

    })

    this.context.start({

    success: (a) => {

    self.isPlaying = true;

    self.startLive();

    },

    fail:(e)=>{

    uni.hideLoading();

    }

    });

    },

    startLive: function() {

    let para = {}

    uni.hideLoading()

    },

    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() {

    uni.showLoading({

    title: "正在关闭"

    })

    this.context.stop({

    success: (a) => {

    self.isPlaying = false;

    console.log("按了stop====" + JSON.stringify(a));

    self.endLive();

    },

    fail:(e)=>{

    uni.hideLoading()

    }

    });

    },

    endLive: function() {

    let para = {}

    uni.hideLoading();

    self.goback();

    },

    switchCamera: function() {

    this.context.switchCamera({

    success: (a) => {

    console.log("livePusher.switchCamera:" + JSON.stringify(a));

    }

    });

    },

    startPreview: function() {

    console.log("this.context===" + this.context);

    this.context.startPreview({

    success: (a) => {

    console.log("livePusher.startPreview:" + JSON.stringify(a));

    uni.hideLoading();

    },

    fail: (e) => {

    console.log("livePusher. err:" + JSON.stringify(e));

    uni.hideLoading();

    },

    });

    },

    stopPreview: function() {

    this.context.stopPreview({

    success: (a) => {

    console.log("livePusher.stopPreview:" + JSON.stringify(a));

    }

    });

    },

    }

    2021-01-19 14:11

DCloud_Android_DQQ

DCloud_Android_DQQ

bug 已确认。
当前版本当设置

:orientation="videoOptions.orientation"

ios 理解得横屏: 采集镜头右转90度,推流数据左转90度
Android理解的横屏: 采集镜头不变,推流数据左转90度

稍后版本修复

DCloud_Android_DQQ

DCloud_Android_DQQ

HX 3.1.0 bug已修复

7***@qq.com

7***@qq.com

能否 禁止通话录音和本地录音权限的提示呢

l***@163.com

l***@163.com

为什么live-pusher里的api调用后都拿不到回调呢

  • Luka1

    我也遇到了,解决了吗

    2022-11-07 16:08

要回复问题请先登录注册