uniapp小程序 推流断流

2021/10/28 20:39:41

本文主要是介绍uniapp小程序 推流断流,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

推流:
this.livePlayer = uni.createLivePlayerContext(“video-livePlay”);
this.url = url;
this.livePlayer.play();

断流1:
this.livePlayer.stop();
this.url = “rtmp://xxxxxxxxxxxxxxx”;
this.livePlayer = uni.createLivePlayerContext(“video-livePlay”);

断流之后的状态码:
2008 Enable default H264 hardware decoder. ->
2103 Enables network reconnection. ->
…三次2103后
-2301 Failed to reconnect many times. Abandon the connection.

断流2
this.livePlayer.stop();
this.url = “”;
this.livePlayer = uni.createLivePlayerContext(“video-livePlay”);

断流之后的状态码:
2008 Enable default H264 hardware decoder. ->
2001 Connected to server. ->
[3005 tcp channel recv fail, errCode[-3] . ->
2103 Enables network reconnection. ->
2001 Connected to server.] ->
…三次[ ]后
3005 tcp channel recv fail, errCode[-3] . ->
-2301 Failed to reconnect many times. Abandon the connection.

断流3
this.livePlayer.stop();
this.url = “”;
this.livePlayer = null;

断流之后的状态码:
2008 Enable default H264 hardware decoder. ->
2001 Connected to server. ->
[3005 tcp channel recv fail, errCode[-3] . ->
2103 Enables network reconnection. ->
2001 Connected to server.] ->
…三次[ ]后
3005 tcp channel recv fail, errCode[-3] . ->
-2301 Failed to reconnect many times. Abandon the connection.

  1. 1和2会黑屏一下再推流,3画面不变直接推流
    通过live-player断流只能报网络断连,不知道为什么
  2. 断流也没有黑屏效果,只能画面停住。黑屏效果可以cover-view写
  3. 推流断流的按钮@click一定要写在button上不能写在cover-view上;
    但是cover-image实现点击效果,@click要写在外面包的cover-view上
  4. 每次推流断流都要重新创建uni.createLivePlayerContext
  5. 如果初始化进入页面就要显示视频,uni.createLivePlayerContext写在onReady里


这篇关于uniapp小程序 推流断流的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程