# Live streaming on WeChat Channels

If Weixin Mini Program is the same entity as the main entity of WeChat Channels or is a related entity, it is possible to navigate to the live streaming room of WeChat Channels or initiate a WeChat Channels live streaming reservation within the mini-program.

# Principal judgment

# Subject information query

Weixin Mini Program The main information can be accessed through the "Development Team" section on the mini-program's information page. The main information for WeChat Channels can be found on the "Certification" page of the WeChat Channels homepage.

WeChat Channelsid is available via Weixin Channels Assistant .

# Subject judgment logic

If Weixin Mini Program is associated with the same entity as the WeChat Channels, the relevant interfaces can be called. If Weixin Mini Program is associated with a different entity than the one responsible for the WeChat Channels, the following three conditions must be met simultaneously for the relevant interface to be called:

  1. Weixin Mini Program Tied to WeChat Open Platform account
  2. Weixin Mini Program and WeChat open platform account as the same subject or associated subject
  3. WeChat The list of main and associated entities for the Open Platform account includes entities related to WeChat Channels https://kf.qq.com/faq/190726e6JFja190726qMJBn6.html

# Obtain live streaming information from WeChat Channels

Developers can use wx.getChannelsLiveInfo The interface retrieves live streaming IDs, live streaming status, live streaming topics, WeChat Channels avatar names, and other live streaming information. The specific usage method is as follows:

Support from the base library 2.15.0

The developer passes in WeChat Channelsid (finderUserName parameter), which can get the live stream information of the current or recent live stream, as follows:

  • Status = 2, live: feedId and nonceId returned are the current live id, description is the current live topic
  • Status = 3, the live stream has ended: feedId and nonceId returned are the most recent live stream id, description is the most recent live stream topic

Support from the base library 2.29.0

Developers upload WeChat Channelsid (finderUserName parameter) and start and end time (startTime and endTime parameters) to get all live information within a specified time period. The live stream or the most recent live stream information will be returned directly in the output, and the rest of the live stream information will be returned as a list in otherInfos.

# How to use it

# Weixin Mini Program Switch to the live streaming room on WeChat Channels

Support from the base library 2.15.0

  1. Developers start with wx.getChannelsLiveInfo The WeChatChannelsid is passed to retrieve live streaming information from WeChat Channels, including the live streaming ID (two parameters: feedId and nonceId) and the live streaming status.

  2. After obtaining the live streaming information, developers can use wx.openChannelsLive to open the live streaming channels on WeChat.If you are not currently live, you will be redirected to the end page of the most recent live stream. The restrictions on the use of this interface are as follows:

  • The user is required to trigger the jump, and if the user does not click anywhere on the Weixin Mini Program page, the developer will not be able to call this interface.
  • The user needs to confirm the redirect. Before redirecting to the live stream on WeChat Channels, a pop-up message will be displayed asking if the user wants to proceed with the redirect. Only after the user confirms will the redirect to the live stream on WeChat Channels be allowed.

# Weixin Mini Program Embedded WeChat Channels Live Streaming

Support from the base library 2.29.0

  1. Developers start with wx.getChannelsLiveInfo The WeChat Channelsid and the start and end times (parameters startTime and endTime) are passed in to retrieve the live streaming information for a specified time period on WeChat Channels, including the live streaming ID (feedId), the live streaming status, and the live streaming playback status.

  2. After obtaining the live streaming information, developers can display the live streaming cover in Weixin Mini Program through the channel-live channel, and users can click on it to directly navigate to the live streaming session on WeChat Channels without any pop-up windows.The transition page to the WeChat Channels page varies depending on the specific live streaming status, as detailed below:

  • Live broadcast did not begin: End page of last live broadcast
  • In live: Live page
  • The live stream has ended (no playback): End of the live stream page
  • The live stream has ended (with playback): Live playback page

# Weixin Mini Program Initiate a reservation for a WeChat Channel live stream

Starting support from the base library 2.19.0

  1. Developers start with wx.getChannelsLiveNoticeInfo The WeChat Channelsid is passed to retrieve the WeChat Channels live broadcast preview id (noticeId). If there are no available live broadcast previews that can be scheduled, an error will be returned.

  2. After obtaining the live preview information, the developer can call the reservation pop-up through wx.reserveChannelsLive , and the user can make the reservation operation.Successfully arouse the pop-up window is the success of the interface call, through the state can get the user's specific operation behavior:

  • State = 1, the live stream, the user clicks "cancel" to refuse to go to the live stream
  • State = 2, is live, the user clicks "allow" to go to live
  • State = 3, the notice has been cancelled
  • State = 4, live broadcast has ended
  • State = 5, the user has not made an appointment before, in the pop-up window did not make an appointment to live directly Close the pop-up window
  • State = 6, the user has not made an appointment before, and has booked a live broadcast in the pop-up window
  • State = 7, the user has already made an appointment and canceled the appointment in the pop-up window.
  • State = 8, the user has previously made an appointment, directly close the pop-up window
  • State = 9, the pop-up window evokes the user directly before canceling
  • State = 10, live reservation has expired

# Use specifications

  1. Wx.getChannelsLiveInfo and wx.getMessageInfo call to the WeChat back-end system resources. To protect the system, developers should adhere to the Interface Call Frequency Specification and Make a modest frequency limit for the interface and not call it uncontrollably.
  2. The platform will resolutely crack down on behaviors such as inducing users to switch to WeChat Channel live streaming or inducing users to make reservations for WeChat Channel live streaming. When using this feature, please strictly adhere to the Weixin Mini Program Platform Operation Guidelines .

# Note

  1. This interface can be called in both the development and the experience versions. During the debugging process, developers can choose the visibility range on WeChat Channels to start broadcasting, making it convenient for testing purposes.
  2. If Weixin Mini Program does not match the main information of the WeChat Channels, a 100008 error code will be returned.
  3. Wx.getChannelsLiveInfo and wx.getChannelsLiveNoticeInfo callback functions do not inherit user click events and cannot be called again in the success callback of wx.getChannelsLive.
  4. Developer tools do not support this capability at this time, so please debug it using the real machine first.