开始推流 暂停推流 resume 停止推流 快照 开启摄像头预览 关闭摄像头预览 切换摄像头 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)); } }); } } }
- 发布:2022-04-01 15:47
- 更新:2022-04-02 10:33
- 阅读:449
【报Bug】ios端nvue进行直播推流,提示"message":"rtmp url invalidate","errMsg":"start:fail"安卓没有问题
产品分类: uniapp/App
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: Windows 10家庭中文版
HBuilderX类型: 正式
HBuilderX版本号: 3.3.13
手机系统: iOS
手机系统版本号: iOS 15
手机厂商: 苹果
手机机型: iphone XR
页面类型: nvue
vue版本: vue2
打包方式: 云端
项目创建方式: HBuilderX
示例代码:
操作步骤:
根据上面的的代码运行即可复现
根据上面的的代码运行即可复现
预期结果:
希望和安卓一样可以直接进行推流服务
希望和安卓一样可以直接进行推流服务
实际结果:
在ios端使用live-pusher无法进行推流
在ios端使用live-pusher无法进行推流
bug描述:
使用live-pusher在ios无法进行推流,this.context.start中返回的fail为{"message":"rtmp url invalidate","errMsg":"start:fail"},同样的代码在安卓没有问题
刘超群 (作者)
已找到问题,可以结帖
2022-04-06 14:34
小娱
回复 刘超群: 遇到同样,是什么问题
2022-11-04 10:17