NIUCLOUD是一款SaaS管理后台框架多应用插件+云编译。上千名开发者、服务商正在积极拥抱开发者生态。欢迎开发者们免费入驻。一起助力发展! 广告
### 最简单的直播推流代码 文件名为index.nvue ~~~ <template> <view> <live-pusher id="livePusher" :url="url" mode="FHD"></live-pusher> <button @click="startLive">开始推流(开始直播)</button> <button @click="stopLive">结束推流</button> </view> </template> <script> export default { data() { return { url: 'rtmp://39.100.248.116/live', enableCamera: false, context: null }; }, onReady() { this.context = uni.createLivePusherContext('livePusher', this); }, methods: { EnableCamera() { this.enableCamera = true; }, startLive() { this.context.start({ success: a => { console.log('livePusher.start:' + JSON.stringify(a)); } }); }, stopLive() { this.context.stop({ success: a => { console.log(JSON.stringify(a)); } }); } } }; </script> ~~~