Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the source code push function of live broadcast and selling goods Mini Program by js

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "js how to achieve live selling Mini Program source code push function". In daily operation, I believe many people have doubts about how to achieve live selling Mini Program source code push function in js. The editor consulted all kinds of materials and sorted out simple and easy-to-use operation methods. I hope it will be helpful to answer the doubts about "how to achieve live selling Mini Program source code push function by js". Next, please follow the editor to study!

1. First, log in to WeChat Mini Programs backend, click "Development"-"API Settings" to enable the permission to record audio and video streams in real time.

2. Use the live-pusher tag to push the Mini Program wxml page. Currently, the Mini Program push URL only supports rtmp format. Click the push button to push the stream.

Start push

3. Js first instantiates push in onready, and previews the push, then click the push button to push, listen for page unloading, and stop push when the page is unloaded.

Page (initial data of {/ * page * / data: {pusherContext:null,// push instance url:'rtmp://',// push instance}, / * Lifecycle function-first rendering of listening page completed * / onReady: function (e) {var _ this = this; / / instantiated push _ this.pusherContext = wx.createLivePusherContext ('livepusher') _ this.pusherContext.startPreview ();}, / * Lifecycle function-- unload the listening page * / onUnload: function () {this.pusherContext.stop () / / stop push}, / * start push * / start:function (e) {this.pusherContext.start ({})} / * push listening * / statechange:function (e) {if (e.detail.code = = 1001) {/ / already connected to the push server} else if (e.detail.code = = 1002) {/ / has finished shaking hands with the server Start push} else if (e.detail.code = = 1003) {/ / enable camera successfully} else if (e.detail.code = = 1004) {/ / Screenshot starts successfully} else if (e.detail.code = = 1005) {/ / push dynamic adjustment resolution} else if (e.detail.code = = 1106) {/ / push dynamic adjustment bitrate} else if (e.detail.code = = 1007) {/ / first frame capture Complete} else if (e.detail.code = = 1008) {/ / Encoder start}} }) so far On the "js how to achieve live sales Mini Program source code push function," the study is over, I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report