刘超群
刘超群
  • 发布:2022-04-01 15:30
  • 更新:2022-04-01 15:45
  • 阅读:253

【报Bug】ios端nvue进行直播推流,提示"message":"rtmp url invalidate","errMsg":"start:fail"安卓没有问题

分类:uni-app

产品分类: uniapp/App

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: Windows 10家庭中文版

HBuilderX类型: 正式

HBuilderX版本号: 3.3.13

手机系统: iOS

手机系统版本号: iOS 15

手机厂商: 苹果

手机机型: iphone XR

页面类型: nvue

vue版本: vue2

打包方式: 云端

项目创建方式: HBuilderX

示例代码:

<template>
<view>
<live-pusher id='livePusher' ref="livePusher" class="livePusher" :url="url"
mode="SD" :muted="true" :enable-camera="true" :auto-focus="true" :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>
import md5 from '@/js_sdk/md5.js';
export default {
data() {
return {
url:'',
context:''
}
},
onReady() {
let that = this;
// 注意:需要在onReady中 或 onLoad 延时
that.context = uni.createLivePusherContext("livePusher", this);
setTimeout(() => {
//this.context = uni.createLivePusherContext('livePusher', this);
var secretdate= 'xxxxxxx'; //测试时此处需要更换
let date = Date.parse(new Date())/1000 + 21600;
//这是需要在腾讯云配置推流的地址,这里采用的是flv的视频格式
that.url = 'http://livepush.nync.com/live/123456789.flv?txSecret='+md5(secretdate+this.live_id+date.toString(16).toUpperCase())+'&txTime='+date.toString(16).toUpperCase();
that.start(0);
}, 1000)
},
methods: {
statechange(e) {
// console.log("statechange:",e);
},
netstatus(e) {
//console.log("netstatus:",e);
},
error(e) {
//console.log("error:",e);
},
start: function() {
this.context.start({
success: (a) => {
console.log("livePusher.start:" + JSON.stringify(a));
},
fail: a =>{
console.log("开启直播失败:" + 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>

操作步骤:

根据上面的的代码运行即可复现

预期结果:

希望和安卓一样可以直接进行推流服务

实际结果:

在ios端使用live-pusher无法进行推流

bug描述:

使用live-pusher在ios无法进行推流,this.context.start中返回的fail为{"message":"rtmp url invalidate","errMsg":"start:fail"},同样的代码在安卓没有问题

2022-04-01 15:30 负责人:天生DR 分享
已邀请:
BoredApe

BoredApe - 有问题就会有答案。

请上传一个能重现问题的测试工程

  • 刘超群 (作者)

    代码都贴出来了

    2022-04-01 15:45

  • 刘超群 (作者)

    官方提供的live-pusher示例代码就不行,以前可以,现在不行了,应该是这两个版本更新出现的问题

    2022-04-01 15:46

  • 天生DR

    回复 刘超群: 代码格式 你没有贴好 看起来是乱的 你可以上传示例demo 压缩成zip 传附件

    2022-04-06 11:03

  • 刘超群 (作者)

    回复 天生DR: 找到问题了,可以结帖

    2022-04-06 14:33

  • 天生DR

    回复 刘超群: 好的

    2022-04-06 17:41

该问题目前已经被锁定, 无法添加新回复